package com.cdp.web.controller.system;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cdp.common.core.domain.AjaxResult;
import com.cdp.common.core.domain.entity.*;
import com.cdp.common.utils.SecurityUtils;
import com.cdp.common.utils.StringUtils;
import com.cdp.common.utils.poi.ExcelUtil;
import com.cdp.system.dto.*;
import com.cdp.system.service.*;
import com.cdp.system.vo.*;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;


@RestController
@RequestMapping("/system/fineness")
public class SysSandFinenessController {

    @Autowired
    private IsysRegionService isysRegionService;

    @Autowired
    private IRegionService regionService;

    @Autowired
    private ISysFlyashService sysFlyashService;

    @Autowired
    private ISysSandFinenesService sysSandFinenesService;

    @Autowired
    private ISysSandTypeService sysSandTypeService;

    @Autowired
    private ISysSandService sysSandService;

    @Autowired
    private ISysStoneGrainService sysStoneGrainService;

    @Autowired
    private ISysFlyashTypeService sysFlyashTypeService;

    @Autowired
    private ISysFlyashFinenessService sysFlyashFinenessService;

    @Autowired
    private ISysWaterReducerTypeService sysWaterReducerTypeService;

    @Autowired
    private ISysCementService sysCementService;

    @Autowired
    private ISysStoneService sysStoneService;

    @Autowired
    private ISysWaterReducerService sysWaterReducerService;

    @Autowired
    private ISysStoneSizeService stoneSizeService;

    @Autowired
    private ISysSourceNameService sysSourceNameService;
    @Autowired
    private ISysEfficiencyMerchantNameService sysEfficiencyMerchantNameService;


    @Autowired
    private ISysMechanicalPerformanceService sysMechanicalPerformanceService;

    @Autowired
    private ISysSlumpService sysSlumpService;

    @Autowired
    private ISysDeformationPerformanceService sysDeformationPerformanceService;

    @Autowired
    private ISysEfficiencyAgentService sysEfficiencyAgent;

    @Autowired
    private ISysDurabilityPerformanceService sysDurabilityPerformanceService;

    @Autowired
    private ISysWaterService waterService;

    @Autowired
    private ISysMineralPowderService sysMineralPowderService;

    @Autowired
    private SysOtherAdmixturesService sysOtherAdmixturesService;


    @Autowired
    private ISysWaterModelService sysWaterModelService;

    @Autowired
    private ISysSwellingagentService sysSwellingagentService;

    @Autowired
    private ISysCementModelService sysCementModelService;


    @Autowired
    private ISysCementStabilityService sysCementStabilityService;

    @Autowired
    private ISysStoneModelService sysStoneModelService;

    @Autowired
    private ISysStoneSpecificationService sysStoneSpecificationService;


    @Autowired
    private ISysStoneParticlesizedistributionService sysStoneParticlesizedistributionService;


    @Autowired
    private ISysMineralModelService sysMineralModelService;

    @Autowired
    private ISysOtherAdmixturesModelService sysOtherAdmixturesModelService;


    @Autowired
    private SysExcelAuditService sysExcelAuditService;

    @Value("${file.excel-mechanical-performance}")
    private String mechanicalPerformanceExcelPath;

    @Autowired
    private IExcelFileHistoryService excelFileHistoryService;

    /**
     * 导出水泥数据
     */
    @PostMapping("queryCementByIdsExport")
    public void queryCementByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        // 从请求体中获取水泥ID列表
        List<Integer> cementIds = rawMaterialsDTO.getCementIds();

        // 创建查询条件，根据水泥ID列表查询
        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SysCement::getCementId, cementIds);

        // 根据ID查询水泥数据
        List<SysCement> cementsList = sysCementService.list(wrapper);

        // 获取地区信息并构建映射
        List<Region> listRegion = regionService.list();
        HashMap<Integer, Region> map = new HashMap<>();
        for (Region region : listRegion) {
            map.put(region.getId(), region);
        }

        // 将SysCement数据转换为CementVO
        List<CementVO> cementsVOlist = new ArrayList<>();
        for (SysCement cement : cementsList) {
            // 创建 CementVO 对象
            CementVO cementVO = new CementVO();

            // 使用BeanUtils将SysCement的属性复制到CementVO中
            BeanUtils.copyProperties(cement, cementVO);

            // 获取地区名称并设置到VO中
            Integer regionId = cement.getRegionName(); // 获取地区ID
            Region region = map.get(regionId);  // 根据regionId查找Region对象
            if (region != null) {
                cementVO.setRegionNameStr(region.getFullName());  // 将地区名称设置到CementVO中
            }

            // 将转换后的CementVO对象加入到结果列表
            cementsVOlist.add(cementVO);
        }

        // 使用ExcelUtil工具类将数据导出为Excel文件
        ExcelUtil<CementVO> util = new ExcelUtil<>(CementVO.class);
        util.exportExcel(response, cementsVOlist, "水泥表");
    }


    /**
     * 导出石头表数据
     */
    @PostMapping("queryStoneByIdsExport")
    public void queryStoneByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        List<Integer> stoneIds = rawMaterialsDTO.getStoneIds();

        LambdaQueryWrapper<SysStone> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SysStone::getStoneId, stoneIds);

        List<SysStone> stoneList = sysStoneService.list(wrapper);

        List<Region> listRegion = regionService.list();
        Map<Integer, Region> regionMap = listRegion.stream().collect(Collectors.toMap(Region::getId, Function.identity()));

        List<StoneVO> stoneVOList = new ArrayList<>();
        for (SysStone stone : stoneList) {
            StoneVO stoneVO = new StoneVO();
            BeanUtils.copyProperties(stone, stoneVO);

            Integer regionId = stone.getRegionName();  // 注意：这里可能应该是 getRegionId()
            Region region = regionMap.get(regionId);
            if (region != null) {
                stoneVO.setRegionNameStr(region.getFullName());
            }

            stoneVOList.add(stoneVO);
        }
        ExcelUtil<StoneVO> util = new ExcelUtil<>(StoneVO.class);
        util.exportExcel(response, stoneVOList, "石子数据导出");
    }


    /**
     * 导出砂表数据
     */
    @PostMapping("querySandByIdsExport")
    public void querySandByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        // 获取前端传入的 sandId 列表
        List<Integer> sandIds = rawMaterialsDTO.getSandIds();

        // 构建查询条件
        LambdaQueryWrapper<SysSand> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SysSand::getSandId, sandIds);

        // 查询砂数据
        List<SysSand> sandList = sysSandService.list(wrapper);

        // 获取地区信息，转换成 Map 以便后续使用
        List<Region> listRegion = regionService.list();
        Map<Integer, Region> regionMap = listRegion.stream()
                .collect(Collectors.toMap(Region::getId, Function.identity()));

        // 准备返回的 VO 列表
        List<SysSandVO> sandVOList = new ArrayList<>();
        for (SysSand sand : sandList) {
            SysSandVO sandVO = new SysSandVO();
            BeanUtils.copyProperties(sand, sandVO);

            // 设置地区名称字符串
            Integer regionId = sand.getRegionName(); // region_name 是 int 类型
            Region region = regionMap.get(regionId);
            if (region != null) {
                sandVO.setRegionNameStr(region.getFullName());
            }

            sandVOList.add(sandVO);
        }

        // 导出 Excel
        ExcelUtil<SysSandVO> util = new ExcelUtil<>(SysSandVO.class);
        util.exportExcel(response, sandVOList, "砂数据导出");
    }


    /**
     * 导出粉煤灰表数据
     */
    @PostMapping("queryFlyashByIdsExport")
    public void queryFlyashByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        // 获取前端传入的 flyashId 列表
        List<Integer> flyashIds = rawMaterialsDTO.getFlyashIds();

        // 构建查询条件，查找粉煤灰数据
        LambdaQueryWrapper<SysFlyash> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SysFlyash::getFlyashId, flyashIds);

        // 查询粉煤灰数据
        List<SysFlyash> flyashList = sysFlyashService.list(wrapper);

        // 获取地区信息，转换成 Map 以便后续使用
        List<Region> listRegion = regionService.list();
        Map<Integer, Region> regionMap = listRegion.stream()
                .collect(Collectors.toMap(Region::getId, Function.identity()));

        // 准备返回的 VO 列表
        List<SysFlyashVO> flyashVOList = new ArrayList<>();
        for (SysFlyash flyash : flyashList) {
            SysFlyashVO flyashVO = new SysFlyashVO();
            BeanUtils.copyProperties(flyash, flyashVO);

            // 设置地区名称字符串
            Integer regionId = flyash.getRegionName(); // region_name 是 int 类型
            Region region = regionMap.get(regionId);
            if (region != null) {
                flyashVO.setRegionNameStr(region.getFullName());
            }

            flyashVOList.add(flyashVO);
        }

        // 导出 Excel
        ExcelUtil<SysFlyashVO> util = new ExcelUtil<>(SysFlyashVO.class);
        util.exportExcel(response, flyashVOList, "粉煤灰数据导出");
    }


    /**
     * 导出矿粉表数据
     */
    /**
     * 导出矿粉表数据
     */
    @PostMapping("queryMineralPowderByIdsExport")
    public void queryMineralPowderByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        // 获取前端传入的矿粉ID列表
        List<Integer> powderIds = rawMaterialsDTO.getPowderIds();

        // 构建查询条件，查找矿粉数据
        LambdaQueryWrapper<SysMineralPowder> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SysMineralPowder::getPowderId, powderIds);

        // 查询矿粉数据
        List<SysMineralPowder> mineralPowderList = sysMineralPowderService.list(wrapper);

        // 获取地区信息，转换成 Map 以便后续使用
        List<Region> listRegion = regionService.list();
        Map<Integer, Region> regionMap = listRegion.stream()
                .collect(Collectors.toMap(Region::getId, Function.identity()));

        // 准备返回的 VO 列表
        List<SysMineralPowderVO> mineralPowderVOList = new ArrayList<>();
        for (SysMineralPowder mineralPowder : mineralPowderList) {
            SysMineralPowderVO mineralPowderVO = new SysMineralPowderVO();
            BeanUtils.copyProperties(mineralPowder, mineralPowderVO);

            // 设置地区名称字符串
            Integer regionId = mineralPowder.getRegionName(); // region_name 是 int 类型
            Region region = regionMap.get(regionId);
            if (region != null) {
                mineralPowderVO.setRegionNameStr(region.getFullName());
            }

            // 将转换后的矿粉VO对象加入到结果列表
            mineralPowderVOList.add(mineralPowderVO);
        }

        // 导出 Excel
        ExcelUtil<SysMineralPowderVO> util = new ExcelUtil<>(SysMineralPowderVO.class);
        util.exportExcel(response, mineralPowderVOList, "矿粉数据导出");
    }


    /**
     * 导出石粉表数据
     */
    @PostMapping("queryOtherAdmixturesByIdsExport")
    public void queryOtherAdmixturesByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        // 获取前端传入的其他掺合料ID列表（这里假设是 rawMaterialsDTO.getAdmixturesIds()）
        List<Integer> admixturesIds = rawMaterialsDTO.getAdmixturesIds();

        // 构建查询条件，查找其他掺合料数据
        LambdaQueryWrapper<SysOtherAdmixtures> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SysOtherAdmixtures::getAdmixturesId, admixturesIds);

        // 查询其他掺合料数据
        List<SysOtherAdmixtures> admixturesList = sysOtherAdmixturesService.list(wrapper);

        // 获取地区信息，转换成 Map 以便后续使用
        List<Region> listRegion = regionService.list();
        Map<Integer, Region> regionMap = listRegion.stream()
                .collect(Collectors.toMap(Region::getId, Function.identity()));

        // 准备返回的 VO 列表
        List<SysOtherAdmixturesVO> admixturesVOList = new ArrayList<>();
        for (SysOtherAdmixtures admixtures : admixturesList) {
            SysOtherAdmixturesVO admixturesVO = new SysOtherAdmixturesVO();
            BeanUtils.copyProperties(admixtures, admixturesVO);

            // 设置地区名称字符串
            Integer regionId = admixtures.getRegionName(); // region_name 是 int 类型
            Region region = regionMap.get(regionId);
            if (region != null) {
                admixturesVO.setRegionNameStr(region.getFullName());
            }

            // 将转换后的掺合料VO对象加入到结果列表
            admixturesVOList.add(admixturesVO);
        }

        // 导出 Excel
        ExcelUtil<SysOtherAdmixturesVO> util = new ExcelUtil<>(SysOtherAdmixturesVO.class);
        util.exportExcel(response, admixturesVOList, "其他掺合料数据导出");
    }


    /**
     * 导出减水剂表数据
     */

    @PostMapping("queryWaterReducerByIdsExport")
    public void queryWaterReducerByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        // 获取前端传入的减水剂ID列表
        List<Integer> waterReducerIds = rawMaterialsDTO.getReducerIds();

        // 构建查询条件，查找减水剂数据
        LambdaQueryWrapper<SysWaterReducer> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SysWaterReducer::getReducerId, waterReducerIds);

        // 查询减水剂数据
        List<SysWaterReducer> reducerList = sysWaterReducerService.list(wrapper);

        // 准备返回的 VO 列表
        List<WaterReducerSecondVO> reducerVOList = new ArrayList<>();
        for (SysWaterReducer reducer : reducerList) {
            WaterReducerSecondVO vo = new WaterReducerSecondVO();
            BeanUtils.copyProperties(reducer, vo);


            reducerVOList.add(vo);
        }

        System.out.println("减水剂数据" + reducerList);

        // 导出 Excel
        ExcelUtil<WaterReducerSecondVO> util = new ExcelUtil<>(WaterReducerSecondVO.class);
        util.exportExcel(response, reducerVOList, "减水剂数据导出");
    }


    /**
     * 导出增效剂表数据
     */

    @PostMapping("queryEfficiencyAgentByIdsExport")
    public void queryEfficiencyAgentByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        // 获取前端传入的增效剂ID列表
        List<Integer> efficiencyAgentIds = rawMaterialsDTO.getEfficiencyAgentIds();

        // 构建查询条件，查找增效剂数据
        LambdaQueryWrapper<SysEfficiencyAgent> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SysEfficiencyAgent::getAgentId, efficiencyAgentIds);

        // 查询增效剂数据
        List<SysEfficiencyAgent> agentList = sysEfficiencyAgent.list(wrapper);

        // 准备返回的 VO 列表
        List<SysEfficiencyAgentVO> agentVOList = new ArrayList<>();
        for (SysEfficiencyAgent agent : agentList) {
            SysEfficiencyAgentVO vo = new SysEfficiencyAgentVO();
            BeanUtils.copyProperties(agent, vo);
            agentVOList.add(vo);
        }

        System.out.println("增效剂数据：" + agentList);

        // 导出 Excel
        ExcelUtil<SysEfficiencyAgentVO> util = new ExcelUtil<>(SysEfficiencyAgentVO.class);
        util.exportExcel(response, agentVOList, "增效剂数据导出");
    }


    /**
     * 导出膨胀剂表数据
     */
    @PostMapping("querySwellingagentByIdsExport")
    public void querySwellingagentByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        // 获取前端传入的膨胀剂ID列表
        List<Integer> swellingagentIds = rawMaterialsDTO.getSwellinggentIds();

        // 构建查询条件，查找膨胀剂数据
        LambdaQueryWrapper<SysSwellingagent> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SysSwellingagent::getSwellingagentId, swellingagentIds);

        // 查询膨胀剂数据
        List<SysSwellingagent> agentList = sysSwellingagentService.list(wrapper);

        // 准备返回的 VO 列表
        List<SwellingagentVO> agentVOList = new ArrayList<>();
        for (SysSwellingagent agent : agentList) {
            SwellingagentVO vo = new SwellingagentVO();
            BeanUtils.copyProperties(agent, vo);
            agentVOList.add(vo);
        }

        System.out.println("膨胀剂数据：" + agentList);

        // 导出 Excel
        ExcelUtil<SwellingagentVO> util = new ExcelUtil<>(SwellingagentVO.class);
        util.exportExcel(response, agentVOList, "膨胀剂数据导出");
    }


    /**
     * 导出力学性能数据
     */
    @PostMapping("queryMechanicalPerformanceByIdsExport")
    public void queryMechanicalPerformanceByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        // 获取前端传入的膨胀剂ID列表

        List<Integer> mechanicalPerformanceIds = rawMaterialsDTO.getMechanicalPerformanceIds();
        // 校验 mechanicalPerformanceIds 不能为空
        if (rawMaterialsDTO.getMechanicalPerformanceIds() == null || rawMaterialsDTO.getMechanicalPerformanceIds().isEmpty()) {
            throw new IllegalArgumentException("请选择要导出的数据");

        }

        // 构建查询条件，查找膨胀剂数据
        LambdaQueryWrapper<SysMechanicalPerformance> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysMechanicalPerformance::getDeleteTime, 0);
        wrapper.in(SysMechanicalPerformance::getId, mechanicalPerformanceIds);

        // 查询力学性能数据
        List<SysMechanicalPerformance> agentList = sysMechanicalPerformanceService.list(wrapper);


        // 获取地区信息，转换成 Map 以便后续使用
        List<Region> listRegion = regionService.list();
        Map<Integer, Region> regionMap = listRegion.stream()
                .collect(Collectors.toMap(Region::getId, Function.identity()));


        // 获取水泥信息，转换成 Map 以便后续使用
        List<SysCement> listCement = sysCementService.list();
        Map<Integer, SysCement> CementMap = listCement.stream()
                .collect(Collectors.toMap(SysCement::getCementId, Function.identity()));


        // 获取水泥信息，转换成 Map 以便后续使用
        List<SysStone> listStone = sysStoneService.list();
        Map<Integer, SysStone> StoneMap = listStone.stream()
                .collect(Collectors.toMap(SysStone::getStoneId, Function.identity()));


        // 获取砂信息，转换成 Map 以便后续使用
        List<SysSand> listSande = sysSandService.list();
        Map<Integer, SysSand> SandeMap = listSande.stream()
                .collect(Collectors.toMap(SysSand::getSandId, Function.identity()));


        // 获取石粉信息，转换成 Map 以便后续使用
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();
        Map<Integer, SysOtherAdmixtures> OtherAdmixturesMap = listOtherAdmixtures.stream()
                .collect(Collectors.toMap(SysOtherAdmixtures::getAdmixturesId, Function.identity()));


        // 获取矿粉信息，转换成 Map 以便后续使用
        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
        Map<Integer, SysMineralPowder> SysMineralPowderMap = listMineralPowder.stream()
                .collect(Collectors.toMap(SysMineralPowder::getPowderId, Function.identity()));

        // 获取粉煤灰信息，转换成 Map 以便后续使用
        List<SysFlyash> listFlyash = sysFlyashService.list();
        Map<Integer, SysFlyash> flyashMap = listFlyash.stream()
                .collect(Collectors.toMap(SysFlyash::getFlyashId, Function.identity()));


        // 获取减水剂信息，转换成 Map 以便后续使用
        List<SysWaterReducer> listSysWaterReducer = sysWaterReducerService.list();
        Map<Integer, SysWaterReducer> SysWaterReducerMap = listSysWaterReducer.stream()
                .collect(Collectors.toMap(SysWaterReducer::getReducerId, Function.identity()));


        // 获取增效剂信息，转换成 Map 以便后续使用
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
        Map<Integer, SysEfficiencyAgent> efficiencyAgentMap = listEfficiencyAgent.stream()
                .collect(Collectors.toMap(SysEfficiencyAgent::getAgentId, Function.identity()));


        // 获取膨胀剂信息，转换成 Map 以便后续使用
        List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
        Map<Integer, SysSwellingagent> swellingagentMap = listSwellingagent.stream()
                .collect(Collectors.toMap(SysSwellingagent::getSwellingagentId, Function.identity()));


        // 准备返回的 VO 列表
        List<SysMechanicalPerformanceThirdVO> agentVOList = new ArrayList<>();
        for (SysMechanicalPerformance smp : agentList) {
            SysMechanicalPerformanceThirdVO vo = new SysMechanicalPerformanceThirdVO();
            BeanUtils.copyProperties(smp, vo);

            // 设置地区名称
            Integer regionId = smp.getRegion();
            Region region = regionMap.get(regionId);
            if (region != null) {
                vo.setRegionNameStr(region.getFullName());
            }

            LocalDateTime productionDate = smp.getProductionDate();
            if (productionDate != null) {
                vo.setProductionDate(productionDate);
            }


            //查询水泥数据
            Integer cementId = smp.getCementId();
            if (cementId != null) {
                SysCement sysCement = CementMap.get(cementId);
                if (sysCement != null) {
                    vo.setCementModel(sysCement.getModel());
                    vo.setCementCaoContent(sysCement.getCaoContent());
                    vo.setCementSio2Content(sysCement.getSio2Content());
                    vo.setCementAl2o3Content(sysCement.getAl2o3Content());
                    vo.setCementCompressiveStrength28d(sysCement.getCompressiveStrength28d());
                    vo.setCementStrengthGrade(sysCement.getStrengthGrade());
                    Integer regionName = sysCement.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setCementRegionNameStr(region1.getFullName());
                        }

                    }
                }


            }


            //石头 5-10
            Integer stone510Id = smp.getStone510Id();
            if (stone510Id != null) {
                SysStone sysStone510 = StoneMap.get(stone510Id);
                if (sysStone510 != null) {
                    System.out.println("哈哈哈510" + sysStone510);
                    vo.setStoneModel510(sysStone510.getModel());
                    vo.setStoneSpecification510(sysStone510.getStoneSpecification());
                    vo.setStoneStackingDensity510(sysStone510.getStackingDensity());
                    vo.setStoneCompactDensity510(sysStone510.getCompactDensity());
                    vo.setStoneBulkdensity510(sysStone510.getBulkDensity());
                    Integer regionNameStone510 = sysStone510.getRegionName();
                    if (regionNameStone510 != null) {
                        Region region1 = regionMap.get(regionNameStone510);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr510(region1.getFullName());
                        }
                    }
                }

            }

            //石头 5-25
            Integer stone525Id = smp.getStone525Id();
            if (stone525Id != null) {
                SysStone sysStone525 = StoneMap.get(stone525Id);
                if (sysStone525 != null) {
                    System.out.println("哈哈哈510" + sysStone525);
                    vo.setStoneModel525(sysStone525.getModel());
                    vo.setStoneSpecification525(sysStone525.getStoneSpecification());
                    vo.setStoneStackingDensity525(sysStone525.getStackingDensity());
                    vo.setStoneCompactDensity525(sysStone525.getCompactDensity());
                    vo.setStoneBulkdensity525(sysStone525.getBulkDensity());
                    Integer regionNameStone525 = sysStone525.getRegionName();
                    if (regionNameStone525 != null) {
                        Region region1 = regionMap.get(regionNameStone525);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr525(region1.getFullName());
                        }
                    }
                }
            }


            //石头 2040
            Integer stone2040Id = smp.getStone525Id();
            if (stone2040Id != null) {
                SysStone sysStone2040 = StoneMap.get(stone2040Id);
                if (sysStone2040 != null) {
                    System.out.println("哈哈哈510" + sysStone2040);
                    vo.setStoneModel2040(sysStone2040.getModel());
                    vo.setStoneSpecification2040(sysStone2040.getStoneSpecification());
                    vo.setStoneStackingDensity2040(sysStone2040.getStackingDensity());
                    vo.setStoneCompactDensity2040(sysStone2040.getCompactDensity());
                    vo.setStoneBulkdensity2040(sysStone2040.getBulkDensity());
                    Integer regionNameStone2040 = sysStone2040.getRegionName();
                    if (regionNameStone2040 != null) {
                        Region region1 = regionMap.get(regionNameStone2040);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr2040(region1.getFullName());
                        }
                    }
                }
            }


            //石头 10-20
            Integer stone1020Id = smp.getStone1020Id();
            if (stone1020Id != null) {
                SysStone sysStone1020 = StoneMap.get(stone1020Id);
                if (sysStone1020 != null) {
                    System.out.println("哈哈哈510" + sysStone1020);
                    vo.setStoneModel1020(sysStone1020.getModel());
                    vo.setStoneSpecification1020(sysStone1020.getStoneSpecification());
                    vo.setStoneStackingDensity1020(sysStone1020.getStackingDensity());
                    vo.setStoneCompactDensity1020(sysStone1020.getCompactDensity());
                    vo.setStoneBulkdensity1020(sysStone1020.getBulkDensity());
                    Integer regionNameStone1020 = sysStone1020.getRegionName();
                    if (regionNameStone1020 != null) {
                        Region region1 = regionMap.get(regionNameStone1020);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr1020(region1.getFullName());
                        }
                    }
                }
            }


            //石头 10-30
            Integer stone1030Id = smp.getStone1030Id();
            if (stone1030Id != null) {
                SysStone sysStone1030 = StoneMap.get(stone1030Id);
                if (sysStone1030 != null) {
                    System.out.println("哈哈哈510" + sysStone1030);
                    vo.setStoneModel1030(sysStone1030.getModel());
                    vo.setStoneSpecification1030(sysStone1030.getStoneSpecification());
                    vo.setStoneStackingDensity1030(sysStone1030.getStackingDensity());
                    vo.setStoneCompactDensity1030(sysStone1030.getCompactDensity());
                    vo.setStoneBulkdensity1030(sysStone1030.getBulkDensity());
                    Integer regionNameStone1030 = sysStone1030.getRegionName();
                    if (regionNameStone1030 != null) {
                        Region region1 = regionMap.get(regionNameStone1030);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr1030(region1.getFullName());
                        }
                    }
                }
            }

            vo.setStone2031(smp.getStoneCoarse20315());
            //石头 0-10
            Integer stone010Id = smp.getStone010Id();
            if (stone010Id != null) {
                SysStone sysStone010 = StoneMap.get(stone010Id);
                if (sysStone010 != null) {

                    vo.setStoneModel010(sysStone010.getModel());
                    vo.setStoneSpecification010(sysStone010.getStoneSpecification());
                    vo.setStoneStackingDensity010(sysStone010.getStackingDensity());
                    vo.setStoneCompactDensity010(sysStone010.getCompactDensity());
                    vo.setStoneBulkdensity010(sysStone010.getBulkDensity());
                    Integer regionNameStone010 = sysStone010.getRegionName();
                    if (regionNameStone010 != null) {
                        Region region1 = regionMap.get(regionNameStone010);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr010(region1.getFullName());
                        }
                    }
                }
            }

            //石头 20-315
            Integer stone20315Id = smp.getStone2031Id();
            if (stone20315Id != null) {
                SysStone sysStone20315 = StoneMap.get(stone20315Id);
                if (sysStone20315 != null) {

                    vo.setStoneModel20315(sysStone20315.getModel());
                    vo.setStoneSpecification20315(sysStone20315.getStoneSpecification());
                    vo.setStoneStackingDensity20315(sysStone20315.getStackingDensity());
                    vo.setStoneCompactDensity20315(sysStone20315.getCompactDensity());
                    vo.setStoneBulkdensity20315(sysStone20315.getBulkDensity());
                    Integer regionNameStone20315 = sysStone20315.getRegionName();
                    if (regionNameStone20315 != null) {
                        Region region1 = regionMap.get(regionNameStone20315);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr20315(region1.getFullName());
                        }
                    }
                }
            }


            //砂31-37
            vo.setSand3137(smp.getSandRiverCoarse3137());
            Integer sandRiverCoarse3137Id = smp.getSandRiverCoarse3137Id();
            if (sandRiverCoarse3137Id != null) {
                SysSand sysSand3137 = SandeMap.get(sandRiverCoarse3137Id);
                if (sysSand3137 != null) {
                    vo.setSandType3137(sysSand3137.getType());
                    vo.setSandFineness3137(sysSand3137.getFineness());
                    vo.setSandBulkDensity3137(sysSand3137.getBulkDensity());
                    vo.setSandCompactDensity3137(sysSand3137.getCompactDensity());
                    vo.setSandApparentDensity3137(sysSand3137.getApparentDensity());
                    vo.setSandParticleSizeDistribution3137(sysSand3137.getParticleSizeDistribution());
                    Integer regionName3137 = sysSand3137.getRegionName();
                    if (regionName3137 != null) {
                        Region region1 = regionMap.get(regionName3137);
                        if (region1 != null) {
                            vo.setSandRegionNameStr3137(region1.getFullName());
                        }
                    }


                }


            }


            //砂23-30
            vo.setSand2330(smp.getSandRiver2330Med());
            Integer sandRiverCoarse2330Id = smp.getSandRiver2330MedId();
            if (sandRiverCoarse2330Id != null) {
                SysSand sysSand2330 = SandeMap.get(sandRiverCoarse2330Id);
                if (sysSand2330 != null) {
                    vo.setSandType2330(sysSand2330.getType());
                    vo.setSandFineness2330(sysSand2330.getFineness());
                    vo.setSandBulkDensity2330(sysSand2330.getBulkDensity());
                    vo.setSandCompactDensity2330(sysSand2330.getCompactDensity());
                    vo.setSandApparentDensity2330(sysSand2330.getApparentDensity());
                    vo.setSandParticleSizeDistribution2330(sysSand2330.getParticleSizeDistribution());
                    Integer regionName2330 = sysSand2330.getRegionName();
                    if (regionName2330 != null) {
                        Region region1 = regionMap.get(regionName2330);
                        if (region1 != null) {
                            vo.setSandRegionNameStr2330(region1.getFullName());
                        }
                    }


                }


            }


            //砂16-22
            vo.setSand1622(smp.getSandRiver1622Fine());
            Integer sandRiverCoarse1622Id = smp.getSandRiver1622FineId();
            if (sandRiverCoarse1622Id != null) {
                SysSand sysSand1622 = SandeMap.get(sandRiverCoarse1622Id);
                if (sysSand1622 != null) {
                    vo.setSandType1622(sysSand1622.getType());
                    vo.setSandFineness1622(sysSand1622.getFineness());
                    vo.setSandBulkDensity1622(sysSand1622.getBulkDensity());
                    vo.setSandCompactDensity1622(sysSand1622.getCompactDensity());
                    vo.setSandApparentDensity1622(sysSand1622.getApparentDensity());
                    vo.setSandParticleSizeDistribution1622(sysSand1622.getParticleSizeDistribution());
                    Integer regionName1622 = sysSand1622.getRegionName();
                    if (regionName1622 != null) {
                        Region region1 = regionMap.get(regionName1622);
                        if (region1 != null) {
                            vo.setSandRegionNameStr1622(region1.getFullName());
                        }
                    }

                }

            }


            //砂2330B
            vo.setSand2330B(smp.getSandMech2330Med());
            Integer sandRiverCoarse2330BId = smp.getSandMech2330MedId();
            if (sandRiverCoarse2330BId != null) {
                SysSand sysSand2330B = SandeMap.get(sandRiverCoarse2330BId);
                if (sysSand2330B != null) {
                    vo.setSandType2330B(sysSand2330B.getType());
                    vo.setSandFineness2330B(sysSand2330B.getFineness());
                    vo.setSandBulkDensity2330B(sysSand2330B.getBulkDensity());
                    vo.setSandCompactDensity2330B(sysSand2330B.getCompactDensity());
                    vo.setSandApparentDensity2330B(sysSand2330B.getApparentDensity());
                    vo.setSandParticleSizeDistribution2330B(sysSand2330B.getParticleSizeDistribution());
                    Integer regionName2330B = sysSand2330B.getRegionName();
                    if (regionName2330B != null) {
                        Region region1 = regionMap.get(regionName2330B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr2330B(region1.getFullName());
                        }
                    }

                }

            }


            //砂31-37B
            vo.setSand3137B(smp.getSandMech3137Coarse());
            Integer sandRiverCoarse3137BId = smp.getSandMech3137CoarseId();
            if (sandRiverCoarse3137BId != null) {
                SysSand sysSand3137B = SandeMap.get(sandRiverCoarse3137BId);
                if (sysSand3137B != null) {
                    vo.setSandType3137B(sysSand3137B.getType());
                    vo.setSandFineness3137B(sysSand3137B.getFineness());
                    vo.setSandBulkDensity3137B(sysSand3137B.getBulkDensity());
                    vo.setSandCompactDensity3137B(sysSand3137B.getCompactDensity());
                    vo.setSandApparentDensity3137B(sysSand3137B.getApparentDensity());
                    vo.setSandParticleSizeDistribution3137B(sysSand3137B.getParticleSizeDistribution());
                    Integer regionName3137B = sysSand3137B.getRegionName();
                    if (regionName3137B != null) {
                        Region region1 = regionMap.get(regionName3137B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr3137B(region1.getFullName());
                        }
                    }

                }
            }


            //砂16-22
            vo.setSand1622B(smp.getSandMech1622Fine());
            Integer sandRiverCoarse1622BId = smp.getSandMech1622FineId();
            if (sandRiverCoarse1622BId != null) {
                SysSand sysSand1622B = SandeMap.get(sandRiverCoarse1622BId);
                if (sysSand1622B != null) {
                    vo.setSandType1622B(sysSand1622B.getType());
                    vo.setSandFineness1622B(sysSand1622B.getFineness());
                    vo.setSandBulkDensity1622B(sysSand1622B.getBulkDensity());
                    vo.setSandCompactDensity1622B(sysSand1622B.getCompactDensity());
                    vo.setSandApparentDensity1622B(sysSand1622B.getApparentDensity());
                    vo.setSandParticleSizeDistribution1622B(sysSand1622B.getParticleSizeDistribution());
                    Integer regionName1622B = sysSand1622B.getRegionName();
                    if (regionName1622B != null) {
                        Region region1 = regionMap.get(regionName1622B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr1622B(region1.getFullName());
                        }
                    }

                }

            }


            //砂04-75
            vo.setSand0475(smp.getSandMech0475());
            Integer sandRiverCoarse0475Id = smp.getSandMech0475Id();
            if (sandRiverCoarse0475Id != null) {
                SysSand sysSand0475 = SandeMap.get(sandRiverCoarse0475Id);
                if (sysSand0475 != null) {
                    vo.setSandType0475(sysSand0475.getType());
                    vo.setSandFineness0475(sysSand0475.getFineness());
                    vo.setSandBulkDensity0475(sysSand0475.getBulkDensity());
                    vo.setSandCompactDensity0475(sysSand0475.getCompactDensity());
                    vo.setSandApparentDensity0475(sysSand0475.getApparentDensity());
                    vo.setSandParticleSizeDistribution0475(sysSand0475.getParticleSizeDistribution());
                    Integer regionName0475 = sysSand0475.getRegionName();
                    if (regionName0475 != null) {
                        Region region1 = regionMap.get(regionName0475);
                        if (region1 != null) {
                            vo.setSandRegionNameStr0475(region1.getFullName());
                        }
                    }

                }
            }

//砂0-9
            vo.setSand09(smp.getSandMech09());
            Integer sandRiverCoarse09Id = smp.getSandMech09Id();
            if (sandRiverCoarse09Id != null) {
                SysSand sysSand09 = SandeMap.get(sandRiverCoarse09Id);
                if (sysSand09 != null) {
                    vo.setSandType09(sysSand09.getType());
                    vo.setSandFineness09(sysSand09.getFineness());
                    vo.setSandBulkDensity09(sysSand09.getBulkDensity());
                    vo.setSandCompactDensity09(sysSand09.getCompactDensity());
                    vo.setSandApparentDensity09(sysSand09.getApparentDensity());
                    vo.setSandParticleSizeDistribution09(sysSand09.getParticleSizeDistribution());
                    Integer regionName09 = sysSand09.getRegionName();
                    if (regionName09 != null) {
                        Region region1 = regionMap.get(regionName09);
                        if (region1 != null) {
                            vo.setSandRegionNameStr09(region1.getFullName());
                        }
                    }

                }
            }


            //石粉
            vo.setAdmixtures(smp.getStonePowder());
            Integer stonePowderId = smp.getStonePowderId();
            if (stonePowderId != null) {
                SysOtherAdmixtures sysOtherAdmixtures = OtherAdmixturesMap.get(stonePowderId);
                if (sysOtherAdmixtures != null) {
                    vo.setAdmixturesModel(sysOtherAdmixtures.getModel());
                    vo.setAdmixturesFineness(sysOtherAdmixtures.getFineness());
                    vo.setAdmixturesMoistureContent(sysOtherAdmixtures.getMoistureContent());
                    vo.setAdmixturesActivityIndex28d(sysOtherAdmixtures.getActivityIndex28d());
                    Integer regionName09 = sysOtherAdmixtures.getRegionName();
                    if (regionName09 != null) {
                        Region region1 = regionMap.get(regionName09);
                        if (region1 != null) {
                            vo.setAdmixturesRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //矿粉
            vo.setMineralPowder(smp.getMineralPowder());
            Integer mineralPowderId = smp.getMineralPowderId();
            if (mineralPowderId != null) {
                SysMineralPowder sysMineralPowder = SysMineralPowderMap.get(mineralPowderId);
                if (sysMineralPowder != null) {
                    vo.setMineralModel(sysMineralPowder.getModel());
                    vo.setMineralSlagGrade(sysMineralPowder.getSlagGrade());
                    vo.setMineralFineness(sysMineralPowder.getFineness());
                    vo.setMineralMoistureContent(sysMineralPowder.getMoistureContent());
                    vo.setMineralActivityIndex28d(sysMineralPowder.getActivityIndex28d());

                    Integer regionName = sysMineralPowder.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setMineralRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //粉煤灰
            vo.setFlyash(smp.getFlyAsh());
            Integer flyAshId = smp.getFlyAshId();
            if (flyAshId != null) {
                SysFlyash sysFlyash = flyashMap.get(flyAshId);
                if (sysFlyash != null) {
                    vo.setFlyashGrade(sysFlyash.getGrade());
                    vo.setFlyashFactoryGrade(sysFlyash.getFactoryGrade());
                    vo.setFlyashFineness(sysFlyash.getFineness());
                    vo.setFlyashMoistureContent(sysFlyash.getMoistureContent());
                    vo.setFlyashActivityIndex28d(sysFlyash.getActivityIndex28d());

                    Integer regionName = sysFlyash.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setFlyashRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //减水剂

            vo.setReducer(smp.getWaterReducer());
            Integer waterReducerId = smp.getWaterReducerId();
            if (waterReducerId != null) {
                SysWaterReducer sysWaterReducer = SysWaterReducerMap.get(waterReducerId);
                if (sysWaterReducer != null) {
                    vo.setReducerModel(sysWaterReducer.getModel());
                    vo.setReducerSolidContent(sysWaterReducer.getSolidContent());
                    vo.setReducerCementPsteFlow(sysWaterReducer.getCementPasteFlow());
                    vo.setReducerReducingRate(sysWaterReducer.getReducingRate());
                    vo.setReducerRegionNameStr(sysWaterReducer.getSourceName());

                }
            }


            //增效剂
            vo.setEfficiencyAgentAgent(smp.getEfficiencyAgent());
            Integer efficiencyAgentId = smp.getEfficiencyAgentId();
            if (efficiencyAgentId != null) {
                SysEfficiencyAgent efficiencyAgent = efficiencyAgentMap.get(efficiencyAgentId);
                if (efficiencyAgent != null) {
                    vo.setEfficiencyAgentModel(efficiencyAgent.getModel());
                    vo.setEfficiencyAgentSourceName(efficiencyAgent.getSourceName());
                }
            }


            //膨胀剂
            vo.setSwellingAgent(smp.getExpansionAgent());
            Integer swellingAgentId = smp.getExpansionAgentId();
            if (swellingAgentId != null) {
                SysSwellingagent sysSwellingagent = swellingagentMap.get(swellingAgentId);
                if (sysSwellingagent != null) {
                    vo.setSwellingagentModel(sysSwellingagent.getModel());
                    vo.setSwellingagentSourceName(sysSwellingagent.getSourceName());

                }
            }


            agentVOList.add(vo);
        }
        System.out.println("膨胀剂数据：" + agentList);

        // 导出 Excel
        ExcelUtil<SysMechanicalPerformanceThirdVO> util = new ExcelUtil<>(SysMechanicalPerformanceThirdVO.class);
        util.exportExcel(response, agentVOList, "力学性能数据导出");
    }







    /**
     * 导出坍落度数据
     */
    @PostMapping("querySlumpByIdsExport")
    public void querySlumpByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
        // 获取前端传入的膨胀剂ID列表
        if (rawMaterialsDTO.getMechanicalPerformanceIds() == null || rawMaterialsDTO.getMechanicalPerformanceIds().isEmpty()) {
            throw new IllegalArgumentException("请选择要导出的数据");

        }
        List<Integer> mechanicalPerformanceIds = rawMaterialsDTO.getMechanicalPerformanceIds();
        // 构建查询条件，查找膨胀剂数据
        LambdaQueryWrapper<SysSlump> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysSlump::getDeleteTime, 0);
        wrapper.in(SysSlump::getId, mechanicalPerformanceIds);

        // 查询力学性能数据
        List<SysSlump> agentList = sysSlumpService.list(wrapper);


        // 获取地区信息，转换成 Map 以便后续使用
        List<Region> listRegion = regionService.list();
        Map<Integer, Region> regionMap = listRegion.stream()
                .collect(Collectors.toMap(Region::getId, Function.identity()));


        // 获取水泥信息，转换成 Map 以便后续使用
        List<SysCement> listCement = sysCementService.list();
        Map<Integer, SysCement> CementMap = listCement.stream()
                .collect(Collectors.toMap(SysCement::getCementId, Function.identity()));


        // 获取水泥信息，转换成 Map 以便后续使用
        List<SysStone> listStone = sysStoneService.list();
        Map<Integer, SysStone> StoneMap = listStone.stream()
                .collect(Collectors.toMap(SysStone::getStoneId, Function.identity()));


        // 获取砂信息，转换成 Map 以便后续使用
        List<SysSand> listSande = sysSandService.list();
        Map<Integer, SysSand> SandeMap = listSande.stream()
                .collect(Collectors.toMap(SysSand::getSandId, Function.identity()));


        // 获取石粉信息，转换成 Map 以便后续使用
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();
        Map<Integer, SysOtherAdmixtures> OtherAdmixturesMap = listOtherAdmixtures.stream()
                .collect(Collectors.toMap(SysOtherAdmixtures::getAdmixturesId, Function.identity()));


        // 获取矿粉信息，转换成 Map 以便后续使用
        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
        Map<Integer, SysMineralPowder> SysMineralPowderMap = listMineralPowder.stream()
                .collect(Collectors.toMap(SysMineralPowder::getPowderId, Function.identity()));

        // 获取粉煤灰信息，转换成 Map 以便后续使用
        List<SysFlyash> listFlyash = sysFlyashService.list();
        Map<Integer, SysFlyash> flyashMap = listFlyash.stream()
                .collect(Collectors.toMap(SysFlyash::getFlyashId, Function.identity()));


        // 获取减水剂信息，转换成 Map 以便后续使用
        List<SysWaterReducer> listSysWaterReducer = sysWaterReducerService.list();
        Map<Integer, SysWaterReducer> SysWaterReducerMap = listSysWaterReducer.stream()
                .collect(Collectors.toMap(SysWaterReducer::getReducerId, Function.identity()));


        // 获取增效剂信息，转换成 Map 以便后续使用
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
        Map<Integer, SysEfficiencyAgent> efficiencyAgentMap = listEfficiencyAgent.stream()
                .collect(Collectors.toMap(SysEfficiencyAgent::getAgentId, Function.identity()));


        // 获取膨胀剂信息，转换成 Map 以便后续使用
        List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
        Map<Integer, SysSwellingagent> swellingagentMap = listSwellingagent.stream()
                .collect(Collectors.toMap(SysSwellingagent::getSwellingagentId, Function.identity()));


        // 准备返回的 VO 列表
        List<SysMechanicalPerformanceFourthVO> agentVOList = new ArrayList<>();
        for (SysSlump smp : agentList) {
            SysMechanicalPerformanceFourthVO vo = new SysMechanicalPerformanceFourthVO();
            BeanUtils.copyProperties(smp, vo);

            // 设置地区名称
            Integer regionId = smp.getRegion();
            Region region = regionMap.get(regionId);
            if (region != null) {
                vo.setRegionNameStr(region.getFullName());
            }

            LocalDateTime productionDate = smp.getProductionDate();
            if (productionDate != null) {
                vo.setProductionDate(productionDate);
            }
            BigDecimal slump = smp.getSlump();
            vo.setStrengthGrade(slump);

            //查询水泥数据
            Integer cementId = smp.getCementId();
            if (cementId != null) {
                SysCement sysCement = CementMap.get(cementId);
                if (sysCement != null) {
                    vo.setCementModel(sysCement.getModel());
                    vo.setCementCaoContent(sysCement.getCaoContent());
                    vo.setCementSio2Content(sysCement.getSio2Content());
                    vo.setCementAl2o3Content(sysCement.getAl2o3Content());
                    vo.setCementCompressiveStrength28d(sysCement.getCompressiveStrength28d());
                    vo.setCementStrengthGrade(sysCement.getStrengthGrade());
                    Integer regionName = sysCement.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setCementRegionNameStr(region1.getFullName());
                        }

                    }
                }


            }


            //石头 5-10
            Integer stone510Id = smp.getStone510Id();
            if (stone510Id != null) {
                SysStone sysStone510 = StoneMap.get(stone510Id);
                if (sysStone510 != null) {
                    System.out.println("哈哈哈510" + sysStone510);
                    vo.setStoneModel510(sysStone510.getModel());
                    vo.setStoneSpecification510(sysStone510.getStoneSpecification());
                    vo.setStoneStackingDensity510(sysStone510.getStackingDensity());
                    vo.setStoneCompactDensity510(sysStone510.getCompactDensity());
                    vo.setStoneBulkdensity510(sysStone510.getBulkDensity());
                    Integer regionNameStone510 = sysStone510.getRegionName();
                    if (regionNameStone510 != null) {
                        Region region1 = regionMap.get(regionNameStone510);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr510(region1.getFullName());
                        }
                    }
                }

            }

            //石头 5-25
            Integer stone525Id = smp.getStone525Id();
            if (stone525Id != null) {
                SysStone sysStone525 = StoneMap.get(stone525Id);
                if (sysStone525 != null) {
                    System.out.println("哈哈哈510" + sysStone525);
                    vo.setStoneModel525(sysStone525.getModel());
                    vo.setStoneSpecification525(sysStone525.getStoneSpecification());
                    vo.setStoneStackingDensity525(sysStone525.getStackingDensity());
                    vo.setStoneCompactDensity525(sysStone525.getCompactDensity());
                    vo.setStoneBulkdensity525(sysStone525.getBulkDensity());
                    Integer regionNameStone525 = sysStone525.getRegionName();
                    if (regionNameStone525 != null) {
                        Region region1 = regionMap.get(regionNameStone525);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr525(region1.getFullName());
                        }
                    }
                }
            }


            //石头 2040
            Integer stone2040Id = smp.getStone525Id();
            if (stone2040Id != null) {
                SysStone sysStone2040 = StoneMap.get(stone2040Id);
                if (sysStone2040 != null) {
                    System.out.println("哈哈哈510" + sysStone2040);
                    vo.setStoneModel2040(sysStone2040.getModel());
                    vo.setStoneSpecification2040(sysStone2040.getStoneSpecification());
                    vo.setStoneStackingDensity2040(sysStone2040.getStackingDensity());
                    vo.setStoneCompactDensity2040(sysStone2040.getCompactDensity());
                    vo.setStoneBulkdensity2040(sysStone2040.getBulkDensity());
                    Integer regionNameStone2040 = sysStone2040.getRegionName();
                    if (regionNameStone2040 != null) {
                        Region region1 = regionMap.get(regionNameStone2040);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr2040(region1.getFullName());
                        }
                    }
                }
            }


            //石头 10-20
            Integer stone1020Id = smp.getStone1020Id();
            if (stone1020Id != null) {
                SysStone sysStone1020 = StoneMap.get(stone1020Id);
                if (sysStone1020 != null) {
                    System.out.println("哈哈哈510" + sysStone1020);
                    vo.setStoneModel1020(sysStone1020.getModel());
                    vo.setStoneSpecification1020(sysStone1020.getStoneSpecification());
                    vo.setStoneStackingDensity1020(sysStone1020.getStackingDensity());
                    vo.setStoneCompactDensity1020(sysStone1020.getCompactDensity());
                    vo.setStoneBulkdensity1020(sysStone1020.getBulkDensity());
                    Integer regionNameStone1020 = sysStone1020.getRegionName();
                    if (regionNameStone1020 != null) {
                        Region region1 = regionMap.get(regionNameStone1020);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr1020(region1.getFullName());
                        }
                    }
                }
            }


            //石头 10-30
            Integer stone1030Id = smp.getStone1030Id();
            if (stone1030Id != null) {
                SysStone sysStone1030 = StoneMap.get(stone1030Id);
                if (sysStone1030 != null) {
                    System.out.println("哈哈哈510" + sysStone1030);
                    vo.setStoneModel1030(sysStone1030.getModel());
                    vo.setStoneSpecification1030(sysStone1030.getStoneSpecification());
                    vo.setStoneStackingDensity1030(sysStone1030.getStackingDensity());
                    vo.setStoneCompactDensity1030(sysStone1030.getCompactDensity());
                    vo.setStoneBulkdensity1030(sysStone1030.getBulkDensity());
                    Integer regionNameStone1030 = sysStone1030.getRegionName();
                    if (regionNameStone1030 != null) {
                        Region region1 = regionMap.get(regionNameStone1030);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr1030(region1.getFullName());
                        }
                    }
                }
            }

            vo.setStone2031(smp.getStoneCoarse20315());
            //石头 0-10
            Integer stone010Id = smp.getStone010Id();
            if (stone010Id != null) {
                SysStone sysStone010 = StoneMap.get(stone010Id);
                if (sysStone010 != null) {

                    vo.setStoneModel010(sysStone010.getModel());
                    vo.setStoneSpecification010(sysStone010.getStoneSpecification());
                    vo.setStoneStackingDensity010(sysStone010.getStackingDensity());
                    vo.setStoneCompactDensity010(sysStone010.getCompactDensity());
                    vo.setStoneBulkdensity010(sysStone010.getBulkDensity());
                    Integer regionNameStone010 = sysStone010.getRegionName();
                    if (regionNameStone010 != null) {
                        Region region1 = regionMap.get(regionNameStone010);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr010(region1.getFullName());
                        }
                    }
                }
            }

            //石头 20-315
            Integer stone20315Id = smp.getStone2031Id();
            if (stone20315Id != null) {
                SysStone sysStone20315 = StoneMap.get(stone20315Id);
                if (sysStone20315 != null) {

                    vo.setStoneModel20315(sysStone20315.getModel());
                    vo.setStoneSpecification20315(sysStone20315.getStoneSpecification());
                    vo.setStoneStackingDensity20315(sysStone20315.getStackingDensity());
                    vo.setStoneCompactDensity20315(sysStone20315.getCompactDensity());
                    vo.setStoneBulkdensity20315(sysStone20315.getBulkDensity());
                    Integer regionNameStone20315 = sysStone20315.getRegionName();
                    if (regionNameStone20315 != null) {
                        Region region1 = regionMap.get(regionNameStone20315);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr20315(region1.getFullName());
                        }
                    }
                }
            }


            //砂31-37
            vo.setSand3137(smp.getSandRiverCoarse3137());
            Integer sandRiverCoarse3137Id = smp.getSandRiverCoarse3137Id();
            if (sandRiverCoarse3137Id != null) {
                SysSand sysSand3137 = SandeMap.get(sandRiverCoarse3137Id);
                if (sysSand3137 != null) {
                    vo.setSandType3137(sysSand3137.getType());
                    vo.setSandFineness3137(sysSand3137.getFineness());
                    vo.setSandBulkDensity3137(sysSand3137.getBulkDensity());
                    vo.setSandCompactDensity3137(sysSand3137.getCompactDensity());
                    vo.setSandApparentDensity3137(sysSand3137.getApparentDensity());
                    vo.setSandParticleSizeDistribution3137(sysSand3137.getParticleSizeDistribution());
                    Integer regionName3137 = sysSand3137.getRegionName();
                    if (regionName3137 != null) {
                        Region region1 = regionMap.get(regionName3137);
                        if (region1 != null) {
                            vo.setSandRegionNameStr3137(region1.getFullName());
                        }
                    }


                }


            }


            //砂23-30
            vo.setSand2330(smp.getSandRiver2330Med());
            Integer sandRiverCoarse2330Id = smp.getSandRiver2330MedId();
            if (sandRiverCoarse2330Id != null) {
                SysSand sysSand2330 = SandeMap.get(sandRiverCoarse2330Id);
                if (sysSand2330 != null) {
                    vo.setSandType2330(sysSand2330.getType());
                    vo.setSandFineness2330(sysSand2330.getFineness());
                    vo.setSandBulkDensity2330(sysSand2330.getBulkDensity());
                    vo.setSandCompactDensity2330(sysSand2330.getCompactDensity());
                    vo.setSandApparentDensity2330(sysSand2330.getApparentDensity());
                    vo.setSandParticleSizeDistribution2330(sysSand2330.getParticleSizeDistribution());
                    Integer regionName2330 = sysSand2330.getRegionName();
                    if (regionName2330 != null) {
                        Region region1 = regionMap.get(regionName2330);
                        if (region1 != null) {
                            vo.setSandRegionNameStr2330(region1.getFullName());
                        }
                    }


                }


            }


            //砂16-22
            vo.setSand1622(smp.getSandRiver1622Fine());
            Integer sandRiverCoarse1622Id = smp.getSandRiver1622FineId();
            if (sandRiverCoarse1622Id != null) {
                SysSand sysSand1622 = SandeMap.get(sandRiverCoarse1622Id);
                if (sysSand1622 != null) {
                    vo.setSandType1622(sysSand1622.getType());
                    vo.setSandFineness1622(sysSand1622.getFineness());
                    vo.setSandBulkDensity1622(sysSand1622.getBulkDensity());
                    vo.setSandCompactDensity1622(sysSand1622.getCompactDensity());
                    vo.setSandApparentDensity1622(sysSand1622.getApparentDensity());
                    vo.setSandParticleSizeDistribution1622(sysSand1622.getParticleSizeDistribution());
                    Integer regionName1622 = sysSand1622.getRegionName();
                    if (regionName1622 != null) {
                        Region region1 = regionMap.get(regionName1622);
                        if (region1 != null) {
                            vo.setSandRegionNameStr1622(region1.getFullName());
                        }
                    }

                }

            }


            //砂2330B
            vo.setSand2330B(smp.getSandMech2330Med());
            Integer sandRiverCoarse2330BId = smp.getSandMech2330MedId();
            if (sandRiverCoarse2330BId != null) {
                SysSand sysSand2330B = SandeMap.get(sandRiverCoarse2330BId);
                if (sysSand2330B != null) {
                    vo.setSandType2330B(sysSand2330B.getType());
                    vo.setSandFineness2330B(sysSand2330B.getFineness());
                    vo.setSandBulkDensity2330B(sysSand2330B.getBulkDensity());
                    vo.setSandCompactDensity2330B(sysSand2330B.getCompactDensity());
                    vo.setSandApparentDensity2330B(sysSand2330B.getApparentDensity());
                    vo.setSandParticleSizeDistribution2330B(sysSand2330B.getParticleSizeDistribution());
                    Integer regionName2330B = sysSand2330B.getRegionName();
                    if (regionName2330B != null) {
                        Region region1 = regionMap.get(regionName2330B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr2330B(region1.getFullName());
                        }
                    }

                }

            }


            //砂31-37B
            vo.setSand3137B(smp.getSandMech3137Coarse());
            Integer sandRiverCoarse3137BId = smp.getSandMech3137CoarseId();
            if (sandRiverCoarse3137BId != null) {
                SysSand sysSand3137B = SandeMap.get(sandRiverCoarse3137BId);
                if (sysSand3137B != null) {
                    vo.setSandType3137B(sysSand3137B.getType());
                    vo.setSandFineness3137B(sysSand3137B.getFineness());
                    vo.setSandBulkDensity3137B(sysSand3137B.getBulkDensity());
                    vo.setSandCompactDensity3137B(sysSand3137B.getCompactDensity());
                    vo.setSandApparentDensity3137B(sysSand3137B.getApparentDensity());
                    vo.setSandParticleSizeDistribution3137B(sysSand3137B.getParticleSizeDistribution());
                    Integer regionName3137B = sysSand3137B.getRegionName();
                    if (regionName3137B != null) {
                        Region region1 = regionMap.get(regionName3137B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr3137B(region1.getFullName());
                        }
                    }

                }
            }


            //砂16-22
            vo.setSand1622B(smp.getSandMech1622Fine());
            Integer sandRiverCoarse1622BId = smp.getSandMech1622FineId();
            if (sandRiverCoarse1622BId != null) {
                SysSand sysSand1622B = SandeMap.get(sandRiverCoarse1622BId);
                if (sysSand1622B != null) {
                    vo.setSandType1622B(sysSand1622B.getType());
                    vo.setSandFineness1622B(sysSand1622B.getFineness());
                    vo.setSandBulkDensity1622B(sysSand1622B.getBulkDensity());
                    vo.setSandCompactDensity1622B(sysSand1622B.getCompactDensity());
                    vo.setSandApparentDensity1622B(sysSand1622B.getApparentDensity());
                    vo.setSandParticleSizeDistribution1622B(sysSand1622B.getParticleSizeDistribution());
                    Integer regionName1622B = sysSand1622B.getRegionName();
                    if (regionName1622B != null) {
                        Region region1 = regionMap.get(regionName1622B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr1622B(region1.getFullName());
                        }
                    }

                }

            }


            //砂04-75
            vo.setSand0475(smp.getSandMech0475());
            Integer sandRiverCoarse0475Id = smp.getSandMech0475Id();
            if (sandRiverCoarse0475Id != null) {
                SysSand sysSand0475 = SandeMap.get(sandRiverCoarse0475Id);
                if (sysSand0475 != null) {
                    vo.setSandType0475(sysSand0475.getType());
                    vo.setSandFineness0475(sysSand0475.getFineness());
                    vo.setSandBulkDensity0475(sysSand0475.getBulkDensity());
                    vo.setSandCompactDensity0475(sysSand0475.getCompactDensity());
                    vo.setSandApparentDensity0475(sysSand0475.getApparentDensity());
                    vo.setSandParticleSizeDistribution0475(sysSand0475.getParticleSizeDistribution());
                    Integer regionName0475 = sysSand0475.getRegionName();
                    if (regionName0475 != null) {
                        Region region1 = regionMap.get(regionName0475);
                        if (region1 != null) {
                            vo.setSandRegionNameStr0475(region1.getFullName());
                        }
                    }

                }
            }

//砂0-9
            vo.setSand09(smp.getSandMech09());
            Integer sandRiverCoarse09Id = smp.getSandMech09Id();
            if (sandRiverCoarse09Id != null) {
                SysSand sysSand09 = SandeMap.get(sandRiverCoarse09Id);
                if (sysSand09 != null) {
                    vo.setSandType09(sysSand09.getType());
                    vo.setSandFineness09(sysSand09.getFineness());
                    vo.setSandBulkDensity09(sysSand09.getBulkDensity());
                    vo.setSandCompactDensity09(sysSand09.getCompactDensity());
                    vo.setSandApparentDensity09(sysSand09.getApparentDensity());
                    vo.setSandParticleSizeDistribution09(sysSand09.getParticleSizeDistribution());
                    Integer regionName09 = sysSand09.getRegionName();
                    if (regionName09 != null) {
                        Region region1 = regionMap.get(regionName09);
                        if (region1 != null) {
                            vo.setSandRegionNameStr09(region1.getFullName());
                        }
                    }

                }
            }


            //石粉
            vo.setAdmixtures(smp.getStonePowder());
            Integer stonePowderId = smp.getStonePowderId();
            if (stonePowderId != null) {
                SysOtherAdmixtures sysOtherAdmixtures = OtherAdmixturesMap.get(stonePowderId);
                if (sysOtherAdmixtures != null) {
                    vo.setAdmixturesModel(sysOtherAdmixtures.getModel());
                    vo.setAdmixturesFineness(sysOtherAdmixtures.getFineness());
                    vo.setAdmixturesMoistureContent(sysOtherAdmixtures.getMoistureContent());
                    vo.setAdmixturesActivityIndex28d(sysOtherAdmixtures.getActivityIndex28d());
                    Integer regionName09 = sysOtherAdmixtures.getRegionName();
                    if (regionName09 != null) {
                        Region region1 = regionMap.get(regionName09);
                        if (region1 != null) {
                            vo.setAdmixturesRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //矿粉
            vo.setMineralPowder(smp.getMineralPowder());
            Integer mineralPowderId = smp.getMineralPowderId();
            if (mineralPowderId != null) {
                SysMineralPowder sysMineralPowder = SysMineralPowderMap.get(mineralPowderId);
                if (sysMineralPowder != null) {
                    vo.setMineralModel(sysMineralPowder.getModel());
                    vo.setMineralSlagGrade(sysMineralPowder.getSlagGrade());
                    vo.setMineralFineness(sysMineralPowder.getFineness());
                    vo.setMineralMoistureContent(sysMineralPowder.getMoistureContent());
                    vo.setMineralActivityIndex28d(sysMineralPowder.getActivityIndex28d());

                    Integer regionName = sysMineralPowder.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setMineralRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //粉煤灰
            vo.setFlyash(smp.getFlyAsh());
            Integer flyAshId = smp.getFlyAshId();
            if (flyAshId != null) {
                SysFlyash sysFlyash = flyashMap.get(flyAshId);
                if (sysFlyash != null) {
                    vo.setFlyashGrade(sysFlyash.getGrade());
                    vo.setFlyashFactoryGrade(sysFlyash.getFactoryGrade());
                    vo.setFlyashFineness(sysFlyash.getFineness());
                    vo.setFlyashMoistureContent(sysFlyash.getMoistureContent());
                    vo.setFlyashActivityIndex28d(sysFlyash.getActivityIndex28d());

                    Integer regionName = sysFlyash.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setFlyashRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //减水剂

            vo.setReducer(smp.getWaterReducer());
            Integer waterReducerId = smp.getWaterReducerId();
            if (waterReducerId != null) {
                SysWaterReducer sysWaterReducer = SysWaterReducerMap.get(waterReducerId);
                if (sysWaterReducer != null) {
                    vo.setReducerModel(sysWaterReducer.getModel());
                    vo.setReducerSolidContent(sysWaterReducer.getSolidContent());
                    vo.setReducerCementPsteFlow(sysWaterReducer.getCementPasteFlow());
                    vo.setReducerReducingRate(sysWaterReducer.getReducingRate());
                    vo.setReducerRegionNameStr(sysWaterReducer.getSourceName());

                }
            }


            //增效剂
            vo.setEfficiencyAgentAgent(smp.getEfficiencyAgent());
            Integer efficiencyAgentId = smp.getEfficiencyAgentId();
            if (efficiencyAgentId != null) {
                SysEfficiencyAgent efficiencyAgent = efficiencyAgentMap.get(efficiencyAgentId);
                if (efficiencyAgent != null) {
                    vo.setEfficiencyAgentModel(efficiencyAgent.getModel());
                    vo.setEfficiencyAgentSourceName(efficiencyAgent.getSourceName());
                }
            }


            //膨胀剂
            vo.setSwellingAgent(smp.getExpansionAgent());
            Integer swellingAgentId = smp.getExpansionAgentId();
            if (swellingAgentId != null) {
                SysSwellingagent sysSwellingagent = swellingagentMap.get(swellingAgentId);
                if (sysSwellingagent != null) {
                    vo.setSwellingagentModel(sysSwellingagent.getModel());
                    vo.setSwellingagentSourceName(sysSwellingagent.getSourceName());

                }
            }


            agentVOList.add(vo);
        }
        System.out.println("膨胀剂数据：" + agentList);

        // 导出 Excel
        ExcelUtil<SysMechanicalPerformanceFourthVO> util = new ExcelUtil<>(SysMechanicalPerformanceFourthVO.class);
        util.exportExcel(response, agentVOList, "坍落度数据导出");
    }


    /**
     * 力学性能
     *
     * @param
     * @param rawMaterialsDTO
     * @return
     */

    @PostMapping("queryMechanicalPerformanceByIdsExportUrl")
    public AjaxResult queryMechanicalPerformanceByIdsExportUrl(@RequestBody RawMaterialsDTO rawMaterialsDTO) {

        // 获取前端传入的膨胀剂ID列表
        List<Integer> mechanicalPerformanceIds = rawMaterialsDTO.getMechanicalPerformanceIds();

        // 构建查询条件，查找膨胀剂数据
        LambdaQueryWrapper<SysMechanicalPerformance> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysMechanicalPerformance::getDeleteTime, 0);
        wrapper.in(SysMechanicalPerformance::getId, mechanicalPerformanceIds);

        // 查询膨胀剂数据
        List<SysMechanicalPerformance> agentList = sysMechanicalPerformanceService.list(wrapper);

        // 获取地区信息，转换成 Map 以便后续使用
        List<Region> listRegion = regionService.list();
        Map<Integer, Region> regionMap = listRegion.stream()
                .collect(Collectors.toMap(Region::getId, Function.identity()));


        // 获取水泥信息，转换成 Map 以便后续使用
        List<SysCement> listCement = sysCementService.list();
        Map<Integer, SysCement> CementMap = listCement.stream()
                .collect(Collectors.toMap(SysCement::getCementId, Function.identity()));


        // 获取水泥信息，转换成 Map 以便后续使用
        List<SysStone> listStone = sysStoneService.list();
        Map<Integer, SysStone> StoneMap = listStone.stream()
                .collect(Collectors.toMap(SysStone::getStoneId, Function.identity()));


        // 获取砂信息，转换成 Map 以便后续使用
        List<SysSand> listSande = sysSandService.list();
        Map<Integer, SysSand> SandeMap = listSande.stream()
                .collect(Collectors.toMap(SysSand::getSandId, Function.identity()));


        // 获取石粉信息，转换成 Map 以便后续使用
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();
        Map<Integer, SysOtherAdmixtures> OtherAdmixturesMap = listOtherAdmixtures.stream()
                .collect(Collectors.toMap(SysOtherAdmixtures::getAdmixturesId, Function.identity()));


        // 获取矿粉信息，转换成 Map 以便后续使用
        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
        Map<Integer, SysMineralPowder> SysMineralPowderMap = listMineralPowder.stream()
                .collect(Collectors.toMap(SysMineralPowder::getPowderId, Function.identity()));

        // 获取粉煤灰信息，转换成 Map 以便后续使用
        List<SysFlyash> listFlyash = sysFlyashService.list();
        Map<Integer, SysFlyash> flyashMap = listFlyash.stream()
                .collect(Collectors.toMap(SysFlyash::getFlyashId, Function.identity()));


        // 获取减水剂信息，转换成 Map 以便后续使用
        List<SysWaterReducer> listSysWaterReducer = sysWaterReducerService.list();
        Map<Integer, SysWaterReducer> SysWaterReducerMap = listSysWaterReducer.stream()
                .collect(Collectors.toMap(SysWaterReducer::getReducerId, Function.identity()));


        // 获取增效剂信息，转换成 Map 以便后续使用
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
        Map<Integer, SysEfficiencyAgent> efficiencyAgentMap = listEfficiencyAgent.stream()
                .collect(Collectors.toMap(SysEfficiencyAgent::getAgentId, Function.identity()));


        // 获取增效剂信息，转换成 Map 以便后续使用
        List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
        Map<Integer, SysSwellingagent> swellingagentMap = listSwellingagent.stream()
                .collect(Collectors.toMap(SysSwellingagent::getSwellingagentId, Function.identity()));

        // 准备返回的 VO 列表
        List<SysMechanicalPerformanceThirdVO> agentVOList = new ArrayList<>();
        for (SysMechanicalPerformance smp : agentList) {
            SysMechanicalPerformanceThirdVO vo = new SysMechanicalPerformanceThirdVO();
            BeanUtils.copyProperties(smp, vo);

            // 设置地区名称
            Integer regionId = smp.getRegion();
            Region region = regionMap.get(regionId);
            if (region != null) {
                vo.setRegionNameStr(region.getFullName());
            }

            LocalDateTime productionDate = smp.getProductionDate();
            if (productionDate != null) {
                vo.setProductionDate(productionDate);
            }


            //查询水泥数据
            Integer cementId = smp.getCementId();
            if (cementId != null) {
                SysCement sysCement = CementMap.get(cementId);
                if (sysCement != null) {
                    vo.setCementModel(sysCement.getModel());
                    vo.setCementCaoContent(sysCement.getCaoContent());
                    vo.setCementSio2Content(sysCement.getSio2Content());
                    vo.setCementAl2o3Content(sysCement.getAl2o3Content());
                    vo.setCementCompressiveStrength28d(sysCement.getCompressiveStrength28d());
                    vo.setCementStrengthGrade(sysCement.getStrengthGrade());
                    Integer regionName = sysCement.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setCementRegionNameStr(region1.getFullName());
                        }

                    }
                }


            }


            //石头 5-10
            Integer stone510Id = smp.getStone510Id();
            if (stone510Id != null) {
                SysStone sysStone510 = StoneMap.get(stone510Id);
                if (sysStone510 != null) {
                    System.out.println("哈哈哈510" + sysStone510);
                    vo.setStoneModel510(sysStone510.getModel());
                    vo.setStoneSpecification510(sysStone510.getStoneSpecification());
                    vo.setStoneStackingDensity510(sysStone510.getStackingDensity());
                    vo.setStoneCompactDensity510(sysStone510.getCompactDensity());
                    vo.setStoneBulkdensity510(sysStone510.getBulkDensity());
                    Integer regionNameStone510 = sysStone510.getRegionName();
                    if (regionNameStone510 != null) {
                        Region region1 = regionMap.get(regionNameStone510);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr510(region1.getFullName());
                        }
                    }
                }

            }

            //石头 5-25
            Integer stone525Id = smp.getStone525Id();
            if (stone525Id != null) {
                SysStone sysStone525 = StoneMap.get(stone525Id);
                if (sysStone525 != null) {
                    System.out.println("哈哈哈510" + sysStone525);
                    vo.setStoneModel525(sysStone525.getModel());
                    vo.setStoneSpecification525(sysStone525.getStoneSpecification());
                    vo.setStoneStackingDensity525(sysStone525.getStackingDensity());
                    vo.setStoneCompactDensity525(sysStone525.getCompactDensity());
                    vo.setStoneBulkdensity525(sysStone525.getBulkDensity());
                    Integer regionNameStone525 = sysStone525.getRegionName();
                    if (regionNameStone525 != null) {
                        Region region1 = regionMap.get(regionNameStone525);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr525(region1.getFullName());
                        }
                    }
                }
            }


            //石头 2040
            Integer stone2040Id = smp.getStone525Id();
            if (stone2040Id != null) {
                SysStone sysStone2040 = StoneMap.get(stone2040Id);
                if (sysStone2040 != null) {
                    System.out.println("哈哈哈510" + sysStone2040);
                    vo.setStoneModel2040(sysStone2040.getModel());
                    vo.setStoneSpecification2040(sysStone2040.getStoneSpecification());
                    vo.setStoneStackingDensity2040(sysStone2040.getStackingDensity());
                    vo.setStoneCompactDensity2040(sysStone2040.getCompactDensity());
                    vo.setStoneBulkdensity2040(sysStone2040.getBulkDensity());
                    Integer regionNameStone2040 = sysStone2040.getRegionName();
                    if (regionNameStone2040 != null) {
                        Region region1 = regionMap.get(regionNameStone2040);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr2040(region1.getFullName());
                        }
                    }
                }
            }


            //石头 10-20
            Integer stone1020Id = smp.getStone1020Id();
            if (stone1020Id != null) {
                SysStone sysStone1020 = StoneMap.get(stone1020Id);
                if (sysStone1020 != null) {
                    System.out.println("哈哈哈510" + sysStone1020);
                    vo.setStoneModel1020(sysStone1020.getModel());
                    vo.setStoneSpecification1020(sysStone1020.getStoneSpecification());
                    vo.setStoneStackingDensity1020(sysStone1020.getStackingDensity());
                    vo.setStoneCompactDensity1020(sysStone1020.getCompactDensity());
                    vo.setStoneBulkdensity1020(sysStone1020.getBulkDensity());
                    Integer regionNameStone1020 = sysStone1020.getRegionName();
                    if (regionNameStone1020 != null) {
                        Region region1 = regionMap.get(regionNameStone1020);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr1020(region1.getFullName());
                        }
                    }
                }
            }


            //石头 10-30
            Integer stone1030Id = smp.getStone1030Id();
            if (stone1030Id != null) {
                SysStone sysStone1030 = StoneMap.get(stone1030Id);
                if (sysStone1030 != null) {
                    System.out.println("哈哈哈510" + sysStone1030);
                    vo.setStoneModel1030(sysStone1030.getModel());
                    vo.setStoneSpecification1030(sysStone1030.getStoneSpecification());
                    vo.setStoneStackingDensity1030(sysStone1030.getStackingDensity());
                    vo.setStoneCompactDensity1030(sysStone1030.getCompactDensity());
                    vo.setStoneBulkdensity1030(sysStone1030.getBulkDensity());
                    Integer regionNameStone1030 = sysStone1030.getRegionName();
                    if (regionNameStone1030 != null) {
                        Region region1 = regionMap.get(regionNameStone1030);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr1030(region1.getFullName());
                        }
                    }
                }
            }

            vo.setStone2031(smp.getStoneCoarse20315());
            //石头 0-10
            Integer stone010Id = smp.getStone010Id();
            if (stone010Id != null) {
                SysStone sysStone010 = StoneMap.get(stone010Id);
                if (sysStone010 != null) {

                    vo.setStoneModel010(sysStone010.getModel());
                    vo.setStoneSpecification010(sysStone010.getStoneSpecification());
                    vo.setStoneStackingDensity010(sysStone010.getStackingDensity());
                    vo.setStoneCompactDensity010(sysStone010.getCompactDensity());
                    vo.setStoneBulkdensity010(sysStone010.getBulkDensity());
                    Integer regionNameStone010 = sysStone010.getRegionName();
                    if (regionNameStone010 != null) {
                        Region region1 = regionMap.get(regionNameStone010);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr010(region1.getFullName());
                        }
                    }
                }
            }

            //石头 20-315
            Integer stone20315Id = smp.getStone2031Id();
            if (stone20315Id != null) {
                SysStone sysStone20315 = StoneMap.get(stone20315Id);
                if (sysStone20315 != null) {

                    vo.setStoneModel20315(sysStone20315.getModel());
                    vo.setStoneSpecification20315(sysStone20315.getStoneSpecification());
                    vo.setStoneStackingDensity20315(sysStone20315.getStackingDensity());
                    vo.setStoneCompactDensity20315(sysStone20315.getCompactDensity());
                    vo.setStoneBulkdensity20315(sysStone20315.getBulkDensity());
                    Integer regionNameStone20315 = sysStone20315.getRegionName();
                    if (regionNameStone20315 != null) {
                        Region region1 = regionMap.get(regionNameStone20315);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr20315(region1.getFullName());
                        }
                    }
                }
            }


            //砂31-37
            vo.setSand3137(smp.getSandRiverCoarse3137());
            Integer sandRiverCoarse3137Id = smp.getSandRiverCoarse3137Id();
            if (sandRiverCoarse3137Id != null) {
                SysSand sysSand3137 = SandeMap.get(sandRiverCoarse3137Id);
                if (sysSand3137 != null) {
                    vo.setSandType3137(sysSand3137.getType());
                    vo.setSandFineness3137(sysSand3137.getFineness());
                    vo.setSandBulkDensity3137(sysSand3137.getBulkDensity());
                    vo.setSandCompactDensity3137(sysSand3137.getCompactDensity());
                    vo.setSandApparentDensity3137(sysSand3137.getApparentDensity());
                    vo.setSandParticleSizeDistribution3137(sysSand3137.getParticleSizeDistribution());
                    Integer regionName3137 = sysSand3137.getRegionName();
                    if (regionName3137 != null) {
                        Region region1 = regionMap.get(regionName3137);
                        if (region1 != null) {
                            vo.setSandRegionNameStr3137(region1.getFullName());
                        }
                    }


                }


            }


            //砂23-30
            vo.setSand2330(smp.getSandRiver2330Med());
            Integer sandRiverCoarse2330Id = smp.getSandRiver2330MedId();
            if (sandRiverCoarse2330Id != null) {
                SysSand sysSand2330 = SandeMap.get(sandRiverCoarse2330Id);
                if (sysSand2330 != null) {
                    vo.setSandType2330(sysSand2330.getType());
                    vo.setSandFineness2330(sysSand2330.getFineness());
                    vo.setSandBulkDensity2330(sysSand2330.getBulkDensity());
                    vo.setSandCompactDensity2330(sysSand2330.getCompactDensity());
                    vo.setSandApparentDensity2330(sysSand2330.getApparentDensity());
                    vo.setSandParticleSizeDistribution2330(sysSand2330.getParticleSizeDistribution());
                    Integer regionName2330 = sysSand2330.getRegionName();
                    if (regionName2330 != null) {
                        Region region1 = regionMap.get(regionName2330);
                        if (region1 != null) {
                            vo.setSandRegionNameStr2330(region1.getFullName());
                        }
                    }


                }


            }


            //砂16-22
            vo.setSand1622(smp.getSandRiver1622Fine());
            Integer sandRiverCoarse1622Id = smp.getSandRiver1622FineId();
            if (sandRiverCoarse1622Id != null) {
                SysSand sysSand1622 = SandeMap.get(sandRiverCoarse1622Id);
                if (sysSand1622 != null) {
                    vo.setSandType1622(sysSand1622.getType());
                    vo.setSandFineness1622(sysSand1622.getFineness());
                    vo.setSandBulkDensity1622(sysSand1622.getBulkDensity());
                    vo.setSandCompactDensity1622(sysSand1622.getCompactDensity());
                    vo.setSandApparentDensity1622(sysSand1622.getApparentDensity());
                    vo.setSandParticleSizeDistribution1622(sysSand1622.getParticleSizeDistribution());
                    Integer regionName1622 = sysSand1622.getRegionName();
                    if (regionName1622 != null) {
                        Region region1 = regionMap.get(regionName1622);
                        if (region1 != null) {
                            vo.setSandRegionNameStr1622(region1.getFullName());
                        }
                    }

                }

            }


            //砂2330B
            vo.setSand2330B(smp.getSandMech2330Med());
            Integer sandRiverCoarse2330BId = smp.getSandMech2330MedId();
            if (sandRiverCoarse2330BId != null) {
                SysSand sysSand2330B = SandeMap.get(sandRiverCoarse2330BId);
                if (sysSand2330B != null) {
                    vo.setSandType2330B(sysSand2330B.getType());
                    vo.setSandFineness2330B(sysSand2330B.getFineness());
                    vo.setSandBulkDensity2330B(sysSand2330B.getBulkDensity());
                    vo.setSandCompactDensity2330B(sysSand2330B.getCompactDensity());
                    vo.setSandApparentDensity2330B(sysSand2330B.getApparentDensity());
                    vo.setSandParticleSizeDistribution2330B(sysSand2330B.getParticleSizeDistribution());
                    Integer regionName2330B = sysSand2330B.getRegionName();
                    if (regionName2330B != null) {
                        Region region1 = regionMap.get(regionName2330B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr2330B(region1.getFullName());
                        }
                    }

                }

            }


            //砂31-37B
            vo.setSand3137B(smp.getSandMech3137Coarse());
            Integer sandRiverCoarse3137BId = smp.getSandMech3137CoarseId();
            if (sandRiverCoarse3137BId != null) {
                SysSand sysSand3137B = SandeMap.get(sandRiverCoarse3137BId);
                if (sysSand3137B != null) {
                    vo.setSandType3137B(sysSand3137B.getType());
                    vo.setSandFineness3137B(sysSand3137B.getFineness());
                    vo.setSandBulkDensity3137B(sysSand3137B.getBulkDensity());
                    vo.setSandCompactDensity3137B(sysSand3137B.getCompactDensity());
                    vo.setSandApparentDensity3137B(sysSand3137B.getApparentDensity());
                    vo.setSandParticleSizeDistribution3137B(sysSand3137B.getParticleSizeDistribution());
                    Integer regionName3137B = sysSand3137B.getRegionName();
                    if (regionName3137B != null) {
                        Region region1 = regionMap.get(regionName3137B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr3137B(region1.getFullName());
                        }
                    }

                }
            }


            //砂16-22
            vo.setSand1622B(smp.getSandMech1622Fine());
            Integer sandRiverCoarse1622BId = smp.getSandMech1622FineId();
            if (sandRiverCoarse1622BId != null) {
                SysSand sysSand1622B = SandeMap.get(sandRiverCoarse1622BId);
                if (sysSand1622B != null) {
                    vo.setSandType1622B(sysSand1622B.getType());
                    vo.setSandFineness1622B(sysSand1622B.getFineness());
                    vo.setSandBulkDensity1622B(sysSand1622B.getBulkDensity());
                    vo.setSandCompactDensity1622B(sysSand1622B.getCompactDensity());
                    vo.setSandApparentDensity1622B(sysSand1622B.getApparentDensity());
                    vo.setSandParticleSizeDistribution1622B(sysSand1622B.getParticleSizeDistribution());
                    Integer regionName1622B = sysSand1622B.getRegionName();
                    if (regionName1622B != null) {
                        Region region1 = regionMap.get(regionName1622B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr1622B(region1.getFullName());
                        }
                    }

                }

            }


            //砂04-75
            vo.setSand0475(smp.getSandMech0475());
            Integer sandRiverCoarse0475Id = smp.getSandMech0475Id();
            if (sandRiverCoarse0475Id != null) {
                SysSand sysSand0475 = SandeMap.get(sandRiverCoarse0475Id);
                if (sysSand0475 != null) {
                    vo.setSandType0475(sysSand0475.getType());
                    vo.setSandFineness0475(sysSand0475.getFineness());
                    vo.setSandBulkDensity0475(sysSand0475.getBulkDensity());
                    vo.setSandCompactDensity0475(sysSand0475.getCompactDensity());
                    vo.setSandApparentDensity0475(sysSand0475.getApparentDensity());
                    vo.setSandParticleSizeDistribution0475(sysSand0475.getParticleSizeDistribution());
                    Integer regionName0475 = sysSand0475.getRegionName();
                    if (regionName0475 != null) {
                        Region region1 = regionMap.get(regionName0475);
                        if (region1 != null) {
                            vo.setSandRegionNameStr0475(region1.getFullName());
                        }
                    }

                }
            }

//砂0-9
            vo.setSand09(smp.getSandMech09());
            Integer sandRiverCoarse09Id = smp.getSandMech09Id();
            if (sandRiverCoarse09Id != null) {
                SysSand sysSand09 = SandeMap.get(sandRiverCoarse09Id);
                if (sysSand09 != null) {
                    vo.setSandType09(sysSand09.getType());
                    vo.setSandFineness09(sysSand09.getFineness());
                    vo.setSandBulkDensity09(sysSand09.getBulkDensity());
                    vo.setSandCompactDensity09(sysSand09.getCompactDensity());
                    vo.setSandApparentDensity09(sysSand09.getApparentDensity());
                    vo.setSandParticleSizeDistribution09(sysSand09.getParticleSizeDistribution());
                    Integer regionName09 = sysSand09.getRegionName();
                    if (regionName09 != null) {
                        Region region1 = regionMap.get(regionName09);
                        if (region1 != null) {
                            vo.setSandRegionNameStr09(region1.getFullName());
                        }
                    }

                }
            }


            //石粉
            vo.setAdmixtures(smp.getStonePowder());
            Integer stonePowderId = smp.getStonePowderId();
            if (stonePowderId != null) {
                SysOtherAdmixtures sysOtherAdmixtures = OtherAdmixturesMap.get(stonePowderId);
                if (sysOtherAdmixtures != null) {
                    vo.setAdmixturesModel(sysOtherAdmixtures.getModel());
                    vo.setAdmixturesFineness(sysOtherAdmixtures.getFineness());
                    vo.setAdmixturesMoistureContent(sysOtherAdmixtures.getMoistureContent());
                    vo.setAdmixturesActivityIndex28d(sysOtherAdmixtures.getActivityIndex28d());
                    Integer regionName09 = sysOtherAdmixtures.getRegionName();
                    if (regionName09 != null) {
                        Region region1 = regionMap.get(regionName09);
                        if (region1 != null) {
                            vo.setAdmixturesRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //矿粉
            vo.setMineralPowder(smp.getMineralPowder());
            Integer mineralPowderId = smp.getMineralPowderId();
            if (mineralPowderId != null) {
                SysMineralPowder sysMineralPowder = SysMineralPowderMap.get(mineralPowderId);
                if (sysMineralPowder != null) {
                    vo.setMineralModel(sysMineralPowder.getModel());
                    vo.setMineralSlagGrade(sysMineralPowder.getSlagGrade());
                    vo.setMineralFineness(sysMineralPowder.getFineness());
                    vo.setMineralMoistureContent(sysMineralPowder.getMoistureContent());
                    vo.setMineralActivityIndex28d(sysMineralPowder.getActivityIndex28d());

                    Integer regionName = sysMineralPowder.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setMineralRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //粉煤灰
            vo.setFlyash(smp.getFlyAsh());
            Integer flyAshId = smp.getFlyAshId();
            if (flyAshId != null) {
                SysFlyash sysFlyash = flyashMap.get(flyAshId);
                if (sysFlyash != null) {
                    vo.setFlyashGrade(sysFlyash.getGrade());
                    vo.setFlyashFactoryGrade(sysFlyash.getFactoryGrade());
                    vo.setFlyashFineness(sysFlyash.getFineness());
                    vo.setFlyashMoistureContent(sysFlyash.getMoistureContent());
                    vo.setFlyashActivityIndex28d(sysFlyash.getActivityIndex28d());

                    Integer regionName = sysFlyash.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setFlyashRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //减水剂

            vo.setReducer(smp.getWaterReducer());
            Integer waterReducerId = smp.getWaterReducerId();
            if (waterReducerId != null) {
                SysWaterReducer sysWaterReducer = SysWaterReducerMap.get(waterReducerId);
                if (sysWaterReducer != null) {
                    vo.setReducerModel(sysWaterReducer.getModel());
                    vo.setReducerSolidContent(sysWaterReducer.getSolidContent());
                    vo.setReducerCementPsteFlow(sysWaterReducer.getCementPasteFlow());
                    vo.setReducerReducingRate(sysWaterReducer.getReducingRate());
                    vo.setReducerRegionNameStr(sysWaterReducer.getSourceName());

                }
            }


            //增效剂
            vo.setEfficiencyAgentAgent(smp.getEfficiencyAgent());
            Integer efficiencyAgentId = smp.getEfficiencyAgentId();
            if (efficiencyAgentId != null) {
                SysEfficiencyAgent efficiencyAgent = efficiencyAgentMap.get(efficiencyAgentId);
                if (efficiencyAgent != null) {
                    vo.setEfficiencyAgentModel(efficiencyAgent.getModel());
                    vo.setEfficiencyAgentSourceName(efficiencyAgent.getSourceName());
                }
            }


            //膨胀剂
            vo.setSwellingAgent(smp.getExpansionAgent());
            Integer swellingAgentId = smp.getExpansionAgentId();
            if (swellingAgentId != null) {
                SysSwellingagent sysSwellingagent = swellingagentMap.get(swellingAgentId);
                if (sysSwellingagent != null) {
                    vo.setSwellingagentModel(sysSwellingagent.getModel());
                    vo.setSwellingagentSourceName(sysSwellingagent.getSourceName());

                }
            }


            agentVOList.add(vo);
        }
        String excelName = rawMaterialsDTO.getExcelName();
        // 生成 Excel 文件并保存到本地
        String filePath = saveExcelToLocal(agentVOList, excelName);

        // 返回文件的 URL
        // 返回 AjaxResult，可以包含文件的 URL
        return AjaxResult.success("文件已生成", filePath);
    }

    // 保存 Excel 文件到本地
    private String saveExcelToLocal(List<SysMechanicalPerformanceThirdVO> agentVOList, String excelName) {
        // 创建 Excel 工具类
        ExcelUtil<SysMechanicalPerformanceThirdVO> util = new ExcelUtil<>(SysMechanicalPerformanceThirdVO.class);


        UUID uuid = UUID.randomUUID();
        int hash = Math.abs(uuid.hashCode()); // 获取 hashCode 并取正数
        int sevenDigitNumber = hash % 10000000; // 取模确保是7位数字以内
        String number = String.format("%03d", sevenDigitNumber); // 补0凑足3位
        // 生成一个唯一的文件名，可以包含时间戳或其他方式
        String fileName = System.currentTimeMillis() + "_" + number + ".xlsx";

        // 设置文件保存路径（这里假设文件存储在服务器的 /uploads/ 文件夹中）
        // String filePath = "C:\\Users\\Administrator\\Desktop\\测试\\excel\\" + fileName;
        String filePath = mechanicalPerformanceExcelPath + fileName;
        // 创建目录（如果不存在）
        File dir = new File(mechanicalPerformanceExcelPath);
        if (!dir.exists()) {
            boolean created = dir.mkdirs(); // 创建目录（支持多级）
            if (created) {
                System.out.println("目录已创建: " + dir.getAbsolutePath());
            } else {
                System.out.println("目录创建失败！");
            }
        }


        ExcelFileHistory excelFileHistory = new ExcelFileHistory();
        excelFileHistory.setFileName(excelName);
        excelFileHistory.setFilePath(filePath);
        excelFileHistory.setCreateTime(LocalDateTime.now());
        excelFileHistory.setDeleteTime(0);
        excelFileHistory.setVersion(0);
        excelFileHistory.setType(0);//力学
        excelFileHistory.setUserId(SecurityUtils.getUserId());
        excelFileHistoryService.save(excelFileHistory);


/*        SysExcelAudit sysExcelAudit = new SysExcelAudit();

        sysExcelAudit.setTableName(excelName);
        sysExcelAudit.setFilePath(filePath);
        sysExcelAudit.setCreateTime(LocalDateTime.now());
        sysExcelAudit.setDeleteTime(0);
        sysExcelAudit.setVersion(0);
        sysExcelAudit.setType(0);//力学
        sysExcelAudit.setUserId(SecurityUtils.getUserId());
        sysExcelAuditService.save(sysExcelAudit);*/


        try {
            // 将数据导出到本地文件
            util.exportExcelToLocal(agentVOList, filePath);
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("导出文件失败", e);
        }

        return filePath;
    }

    private String saveExcelToLocalV2(List<SysMechanicalPerformanceThirdVO> agentVOList, String excelName) {
        // 创建 Excel 工具类
        ExcelUtil<SysMechanicalPerformanceThirdVO> util = new ExcelUtil<>(SysMechanicalPerformanceThirdVO.class);


        UUID uuid = UUID.randomUUID();
        int hash = Math.abs(uuid.hashCode()); // 获取 hashCode 并取正数
        int sevenDigitNumber = hash % 10000000; // 取模确保是7位数字以内
        String number = String.format("%03d", sevenDigitNumber); // 补0凑足3位
        // 生成一个唯一的文件名，可以包含时间戳或其他方式
        String fileName = System.currentTimeMillis() + "_" + number + ".xlsx";

        // 设置文件保存路径（这里假设文件存储在服务器的 /uploads/ 文件夹中）
        // String filePath = "C:\\Users\\Administrator\\Desktop\\测试\\excel\\" + fileName;
        String filePath = mechanicalPerformanceExcelPath + fileName;
        // 创建目录（如果不存在）
        File dir = new File(mechanicalPerformanceExcelPath);
        if (!dir.exists()) {
            boolean created = dir.mkdirs(); // 创建目录（支持多级）
            if (created) {
                System.out.println("目录已创建: " + dir.getAbsolutePath());
            } else {
                System.out.println("目录创建失败！");
            }
        }


/*        ExcelFileHistory excelFileHistory = new ExcelFileHistory();
        excelFileHistory.setFileName(excelName);
        excelFileHistory.setFilePath(filePath);
        excelFileHistory.setCreateTime(LocalDateTime.now());
        excelFileHistory.setDeleteTime(0);
        excelFileHistory.setVersion(0);
        excelFileHistory.setType(0);//力学
        excelFileHistory.setUserId(SecurityUtils.getUserId());
        excelFileHistoryService.save(excelFileHistory);*/


/*        SysExcelAudit sysExcelAudit = new SysExcelAudit();

        sysExcelAudit.setTableName(excelName);
        sysExcelAudit.setFilePath(filePath);
        sysExcelAudit.setCreateTime(LocalDateTime.now());
        sysExcelAudit.setDeleteTime(0);
        sysExcelAudit.setVersion(0);
        sysExcelAudit.setType(0);//力学
        sysExcelAudit.setUserId(SecurityUtils.getUserId());
        sysExcelAuditService.save(sysExcelAudit);*/


        try {
            // 将数据导出到本地文件
            util.exportExcelToLocal(agentVOList, filePath);
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("导出文件失败", e);
        }

        return filePath;
    }

    /**
     * 坍落度
     *
     * @param response
     * @param rawMaterialsDTO
     * @return
     */

    @PostMapping("querySlumpByIdsExportUrl")
    public AjaxResult querySlumpByIdsExportUrl(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {

        // 获取前端传入的膨胀剂ID列表

        List<Integer> mechanicalPerformanceIds = rawMaterialsDTO.getMechanicalPerformanceIds();
        // 构建查询条件，查找膨胀剂数据
        LambdaQueryWrapper<SysSlump> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysSlump::getDeleteTime, 0);
        wrapper.in(SysSlump::getId, mechanicalPerformanceIds);

        // 查询力学性能数据
        List<SysSlump> agentList = sysSlumpService.list(wrapper);


        // 获取地区信息，转换成 Map 以便后续使用
        List<Region> listRegion = regionService.list();
        Map<Integer, Region> regionMap = listRegion.stream()
                .collect(Collectors.toMap(Region::getId, Function.identity()));


        // 获取水泥信息，转换成 Map 以便后续使用
        List<SysCement> listCement = sysCementService.list();
        Map<Integer, SysCement> CementMap = listCement.stream()
                .collect(Collectors.toMap(SysCement::getCementId, Function.identity()));


        // 获取水泥信息，转换成 Map 以便后续使用
        List<SysStone> listStone = sysStoneService.list();
        Map<Integer, SysStone> StoneMap = listStone.stream()
                .collect(Collectors.toMap(SysStone::getStoneId, Function.identity()));


        // 获取砂信息，转换成 Map 以便后续使用
        List<SysSand> listSande = sysSandService.list();
        Map<Integer, SysSand> SandeMap = listSande.stream()
                .collect(Collectors.toMap(SysSand::getSandId, Function.identity()));


        // 获取石粉信息，转换成 Map 以便后续使用
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();
        Map<Integer, SysOtherAdmixtures> OtherAdmixturesMap = listOtherAdmixtures.stream()
                .collect(Collectors.toMap(SysOtherAdmixtures::getAdmixturesId, Function.identity()));


        // 获取矿粉信息，转换成 Map 以便后续使用
        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
        Map<Integer, SysMineralPowder> SysMineralPowderMap = listMineralPowder.stream()
                .collect(Collectors.toMap(SysMineralPowder::getPowderId, Function.identity()));

        // 获取粉煤灰信息，转换成 Map 以便后续使用
        List<SysFlyash> listFlyash = sysFlyashService.list();
        Map<Integer, SysFlyash> flyashMap = listFlyash.stream()
                .collect(Collectors.toMap(SysFlyash::getFlyashId, Function.identity()));


        // 获取减水剂信息，转换成 Map 以便后续使用
        List<SysWaterReducer> listSysWaterReducer = sysWaterReducerService.list();
        Map<Integer, SysWaterReducer> SysWaterReducerMap = listSysWaterReducer.stream()
                .collect(Collectors.toMap(SysWaterReducer::getReducerId, Function.identity()));


        // 获取增效剂信息，转换成 Map 以便后续使用
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
        Map<Integer, SysEfficiencyAgent> efficiencyAgentMap = listEfficiencyAgent.stream()
                .collect(Collectors.toMap(SysEfficiencyAgent::getAgentId, Function.identity()));


        // 获取膨胀剂信息，转换成 Map 以便后续使用
        List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
        Map<Integer, SysSwellingagent> swellingagentMap = listSwellingagent.stream()
                .collect(Collectors.toMap(SysSwellingagent::getSwellingagentId, Function.identity()));


        // 准备返回的 VO 列表
        List<SysMechanicalPerformanceFourthVO> agentVOList = new ArrayList<>();
        for (SysSlump smp : agentList) {
            SysMechanicalPerformanceFourthVO vo = new SysMechanicalPerformanceFourthVO();
            BeanUtils.copyProperties(smp, vo);

            // 设置地区名称
            Integer regionId = smp.getRegion();
            Region region = regionMap.get(regionId);
            if (region != null) {
                vo.setRegionNameStr(region.getFullName());
            }

            LocalDateTime productionDate = smp.getProductionDate();
            if (productionDate != null) {
                vo.setProductionDate(productionDate);
            }
            BigDecimal slump = smp.getSlump();
            vo.setStrengthGrade(slump);

            //查询水泥数据
            Integer cementId = smp.getCementId();
            if (cementId != null) {
                SysCement sysCement = CementMap.get(cementId);
                if (sysCement != null) {
                    vo.setCementModel(sysCement.getModel());
                    vo.setCementCaoContent(sysCement.getCaoContent());
                    vo.setCementSio2Content(sysCement.getSio2Content());
                    vo.setCementAl2o3Content(sysCement.getAl2o3Content());
                    vo.setCementCompressiveStrength28d(sysCement.getCompressiveStrength28d());
                    vo.setCementStrengthGrade(sysCement.getStrengthGrade());
                    Integer regionName = sysCement.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setCementRegionNameStr(region1.getFullName());
                        }

                    }
                }


            }


            //石头 5-10
            Integer stone510Id = smp.getStone510Id();
            if (stone510Id != null) {
                SysStone sysStone510 = StoneMap.get(stone510Id);
                if (sysStone510 != null) {
                    System.out.println("哈哈哈510" + sysStone510);
                    vo.setStoneModel510(sysStone510.getModel());
                    vo.setStoneSpecification510(sysStone510.getStoneSpecification());
                    vo.setStoneStackingDensity510(sysStone510.getStackingDensity());
                    vo.setStoneCompactDensity510(sysStone510.getCompactDensity());
                    vo.setStoneBulkdensity510(sysStone510.getBulkDensity());
                    Integer regionNameStone510 = sysStone510.getRegionName();
                    if (regionNameStone510 != null) {
                        Region region1 = regionMap.get(regionNameStone510);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr510(region1.getFullName());
                        }
                    }
                }

            }

            //石头 5-25
            Integer stone525Id = smp.getStone525Id();
            if (stone525Id != null) {
                SysStone sysStone525 = StoneMap.get(stone525Id);
                if (sysStone525 != null) {
                    System.out.println("哈哈哈510" + sysStone525);
                    vo.setStoneModel525(sysStone525.getModel());
                    vo.setStoneSpecification525(sysStone525.getStoneSpecification());
                    vo.setStoneStackingDensity525(sysStone525.getStackingDensity());
                    vo.setStoneCompactDensity525(sysStone525.getCompactDensity());
                    vo.setStoneBulkdensity525(sysStone525.getBulkDensity());
                    Integer regionNameStone525 = sysStone525.getRegionName();
                    if (regionNameStone525 != null) {
                        Region region1 = regionMap.get(regionNameStone525);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr525(region1.getFullName());
                        }
                    }
                }
            }


            //石头 2040
            Integer stone2040Id = smp.getStone525Id();
            if (stone2040Id != null) {
                SysStone sysStone2040 = StoneMap.get(stone2040Id);
                if (sysStone2040 != null) {
                    System.out.println("哈哈哈510" + sysStone2040);
                    vo.setStoneModel2040(sysStone2040.getModel());
                    vo.setStoneSpecification2040(sysStone2040.getStoneSpecification());
                    vo.setStoneStackingDensity2040(sysStone2040.getStackingDensity());
                    vo.setStoneCompactDensity2040(sysStone2040.getCompactDensity());
                    vo.setStoneBulkdensity2040(sysStone2040.getBulkDensity());
                    Integer regionNameStone2040 = sysStone2040.getRegionName();
                    if (regionNameStone2040 != null) {
                        Region region1 = regionMap.get(regionNameStone2040);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr2040(region1.getFullName());
                        }
                    }
                }
            }


            //石头 10-20
            Integer stone1020Id = smp.getStone1020Id();
            if (stone1020Id != null) {
                SysStone sysStone1020 = StoneMap.get(stone1020Id);
                if (sysStone1020 != null) {
                    System.out.println("哈哈哈510" + sysStone1020);
                    vo.setStoneModel1020(sysStone1020.getModel());
                    vo.setStoneSpecification1020(sysStone1020.getStoneSpecification());
                    vo.setStoneStackingDensity1020(sysStone1020.getStackingDensity());
                    vo.setStoneCompactDensity1020(sysStone1020.getCompactDensity());
                    vo.setStoneBulkdensity1020(sysStone1020.getBulkDensity());
                    Integer regionNameStone1020 = sysStone1020.getRegionName();
                    if (regionNameStone1020 != null) {
                        Region region1 = regionMap.get(regionNameStone1020);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr1020(region1.getFullName());
                        }
                    }
                }
            }


            //石头 10-30
            Integer stone1030Id = smp.getStone1030Id();
            if (stone1030Id != null) {
                SysStone sysStone1030 = StoneMap.get(stone1030Id);
                if (sysStone1030 != null) {
                    System.out.println("哈哈哈510" + sysStone1030);
                    vo.setStoneModel1030(sysStone1030.getModel());
                    vo.setStoneSpecification1030(sysStone1030.getStoneSpecification());
                    vo.setStoneStackingDensity1030(sysStone1030.getStackingDensity());
                    vo.setStoneCompactDensity1030(sysStone1030.getCompactDensity());
                    vo.setStoneBulkdensity1030(sysStone1030.getBulkDensity());
                    Integer regionNameStone1030 = sysStone1030.getRegionName();
                    if (regionNameStone1030 != null) {
                        Region region1 = regionMap.get(regionNameStone1030);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr1030(region1.getFullName());
                        }
                    }
                }
            }

            vo.setStone2031(smp.getStoneCoarse20315());
            //石头 0-10
            Integer stone010Id = smp.getStone010Id();
            if (stone010Id != null) {
                SysStone sysStone010 = StoneMap.get(stone010Id);
                if (sysStone010 != null) {

                    vo.setStoneModel010(sysStone010.getModel());
                    vo.setStoneSpecification010(sysStone010.getStoneSpecification());
                    vo.setStoneStackingDensity010(sysStone010.getStackingDensity());
                    vo.setStoneCompactDensity010(sysStone010.getCompactDensity());
                    vo.setStoneBulkdensity010(sysStone010.getBulkDensity());
                    Integer regionNameStone010 = sysStone010.getRegionName();
                    if (regionNameStone010 != null) {
                        Region region1 = regionMap.get(regionNameStone010);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr010(region1.getFullName());
                        }
                    }
                }
            }

            //石头 20-315
            Integer stone20315Id = smp.getStone2031Id();
            if (stone20315Id != null) {
                SysStone sysStone20315 = StoneMap.get(stone20315Id);
                if (sysStone20315 != null) {

                    vo.setStoneModel20315(sysStone20315.getModel());
                    vo.setStoneSpecification20315(sysStone20315.getStoneSpecification());
                    vo.setStoneStackingDensity20315(sysStone20315.getStackingDensity());
                    vo.setStoneCompactDensity20315(sysStone20315.getCompactDensity());
                    vo.setStoneBulkdensity20315(sysStone20315.getBulkDensity());
                    Integer regionNameStone20315 = sysStone20315.getRegionName();
                    if (regionNameStone20315 != null) {
                        Region region1 = regionMap.get(regionNameStone20315);
                        if (region1 != null) {
                            vo.setStoneRegionNameStr20315(region1.getFullName());
                        }
                    }
                }
            }


            //砂31-37
            vo.setSand3137(smp.getSandRiverCoarse3137());
            Integer sandRiverCoarse3137Id = smp.getSandRiverCoarse3137Id();
            if (sandRiverCoarse3137Id != null) {
                SysSand sysSand3137 = SandeMap.get(sandRiverCoarse3137Id);
                if (sysSand3137 != null) {
                    vo.setSandType3137(sysSand3137.getType());
                    vo.setSandFineness3137(sysSand3137.getFineness());
                    vo.setSandBulkDensity3137(sysSand3137.getBulkDensity());
                    vo.setSandCompactDensity3137(sysSand3137.getCompactDensity());
                    vo.setSandApparentDensity3137(sysSand3137.getApparentDensity());
                    vo.setSandParticleSizeDistribution3137(sysSand3137.getParticleSizeDistribution());
                    Integer regionName3137 = sysSand3137.getRegionName();
                    if (regionName3137 != null) {
                        Region region1 = regionMap.get(regionName3137);
                        if (region1 != null) {
                            vo.setSandRegionNameStr3137(region1.getFullName());
                        }
                    }


                }


            }


            //砂23-30
            vo.setSand2330(smp.getSandRiver2330Med());
            Integer sandRiverCoarse2330Id = smp.getSandRiver2330MedId();
            if (sandRiverCoarse2330Id != null) {
                SysSand sysSand2330 = SandeMap.get(sandRiverCoarse2330Id);
                if (sysSand2330 != null) {
                    vo.setSandType2330(sysSand2330.getType());
                    vo.setSandFineness2330(sysSand2330.getFineness());
                    vo.setSandBulkDensity2330(sysSand2330.getBulkDensity());
                    vo.setSandCompactDensity2330(sysSand2330.getCompactDensity());
                    vo.setSandApparentDensity2330(sysSand2330.getApparentDensity());
                    vo.setSandParticleSizeDistribution2330(sysSand2330.getParticleSizeDistribution());
                    Integer regionName2330 = sysSand2330.getRegionName();
                    if (regionName2330 != null) {
                        Region region1 = regionMap.get(regionName2330);
                        if (region1 != null) {
                            vo.setSandRegionNameStr2330(region1.getFullName());
                        }
                    }


                }


            }


            //砂16-22
            vo.setSand1622(smp.getSandRiver1622Fine());
            Integer sandRiverCoarse1622Id = smp.getSandRiver1622FineId();
            if (sandRiverCoarse1622Id != null) {
                SysSand sysSand1622 = SandeMap.get(sandRiverCoarse1622Id);
                if (sysSand1622 != null) {
                    vo.setSandType1622(sysSand1622.getType());
                    vo.setSandFineness1622(sysSand1622.getFineness());
                    vo.setSandBulkDensity1622(sysSand1622.getBulkDensity());
                    vo.setSandCompactDensity1622(sysSand1622.getCompactDensity());
                    vo.setSandApparentDensity1622(sysSand1622.getApparentDensity());
                    vo.setSandParticleSizeDistribution1622(sysSand1622.getParticleSizeDistribution());
                    Integer regionName1622 = sysSand1622.getRegionName();
                    if (regionName1622 != null) {
                        Region region1 = regionMap.get(regionName1622);
                        if (region1 != null) {
                            vo.setSandRegionNameStr1622(region1.getFullName());
                        }
                    }

                }

            }


            //砂2330B
            vo.setSand2330B(smp.getSandMech2330Med());
            Integer sandRiverCoarse2330BId = smp.getSandMech2330MedId();
            if (sandRiverCoarse2330BId != null) {
                SysSand sysSand2330B = SandeMap.get(sandRiverCoarse2330BId);
                if (sysSand2330B != null) {
                    vo.setSandType2330B(sysSand2330B.getType());
                    vo.setSandFineness2330B(sysSand2330B.getFineness());
                    vo.setSandBulkDensity2330B(sysSand2330B.getBulkDensity());
                    vo.setSandCompactDensity2330B(sysSand2330B.getCompactDensity());
                    vo.setSandApparentDensity2330B(sysSand2330B.getApparentDensity());
                    vo.setSandParticleSizeDistribution2330B(sysSand2330B.getParticleSizeDistribution());
                    Integer regionName2330B = sysSand2330B.getRegionName();
                    if (regionName2330B != null) {
                        Region region1 = regionMap.get(regionName2330B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr2330B(region1.getFullName());
                        }
                    }

                }

            }


            //砂31-37B
            vo.setSand3137B(smp.getSandMech3137Coarse());
            Integer sandRiverCoarse3137BId = smp.getSandMech3137CoarseId();
            if (sandRiverCoarse3137BId != null) {
                SysSand sysSand3137B = SandeMap.get(sandRiverCoarse3137BId);
                if (sysSand3137B != null) {
                    vo.setSandType3137B(sysSand3137B.getType());
                    vo.setSandFineness3137B(sysSand3137B.getFineness());
                    vo.setSandBulkDensity3137B(sysSand3137B.getBulkDensity());
                    vo.setSandCompactDensity3137B(sysSand3137B.getCompactDensity());
                    vo.setSandApparentDensity3137B(sysSand3137B.getApparentDensity());
                    vo.setSandParticleSizeDistribution3137B(sysSand3137B.getParticleSizeDistribution());
                    Integer regionName3137B = sysSand3137B.getRegionName();
                    if (regionName3137B != null) {
                        Region region1 = regionMap.get(regionName3137B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr3137B(region1.getFullName());
                        }
                    }

                }
            }


            //砂16-22
            vo.setSand1622B(smp.getSandMech1622Fine());
            Integer sandRiverCoarse1622BId = smp.getSandMech1622FineId();
            if (sandRiverCoarse1622BId != null) {
                SysSand sysSand1622B = SandeMap.get(sandRiverCoarse1622BId);
                if (sysSand1622B != null) {
                    vo.setSandType1622B(sysSand1622B.getType());
                    vo.setSandFineness1622B(sysSand1622B.getFineness());
                    vo.setSandBulkDensity1622B(sysSand1622B.getBulkDensity());
                    vo.setSandCompactDensity1622B(sysSand1622B.getCompactDensity());
                    vo.setSandApparentDensity1622B(sysSand1622B.getApparentDensity());
                    vo.setSandParticleSizeDistribution1622B(sysSand1622B.getParticleSizeDistribution());
                    Integer regionName1622B = sysSand1622B.getRegionName();
                    if (regionName1622B != null) {
                        Region region1 = regionMap.get(regionName1622B);
                        if (region1 != null) {
                            vo.setSandRegionNameStr1622B(region1.getFullName());
                        }
                    }

                }

            }


            //砂04-75
            vo.setSand0475(smp.getSandMech0475());
            Integer sandRiverCoarse0475Id = smp.getSandMech0475Id();
            if (sandRiverCoarse0475Id != null) {
                SysSand sysSand0475 = SandeMap.get(sandRiverCoarse0475Id);
                if (sysSand0475 != null) {
                    vo.setSandType0475(sysSand0475.getType());
                    vo.setSandFineness0475(sysSand0475.getFineness());
                    vo.setSandBulkDensity0475(sysSand0475.getBulkDensity());
                    vo.setSandCompactDensity0475(sysSand0475.getCompactDensity());
                    vo.setSandApparentDensity0475(sysSand0475.getApparentDensity());
                    vo.setSandParticleSizeDistribution0475(sysSand0475.getParticleSizeDistribution());
                    Integer regionName0475 = sysSand0475.getRegionName();
                    if (regionName0475 != null) {
                        Region region1 = regionMap.get(regionName0475);
                        if (region1 != null) {
                            vo.setSandRegionNameStr0475(region1.getFullName());
                        }
                    }

                }
            }

//砂0-9
            vo.setSand09(smp.getSandMech09());
            Integer sandRiverCoarse09Id = smp.getSandMech09Id();
            if (sandRiverCoarse09Id != null) {
                SysSand sysSand09 = SandeMap.get(sandRiverCoarse09Id);
                if (sysSand09 != null) {
                    vo.setSandType09(sysSand09.getType());
                    vo.setSandFineness09(sysSand09.getFineness());
                    vo.setSandBulkDensity09(sysSand09.getBulkDensity());
                    vo.setSandCompactDensity09(sysSand09.getCompactDensity());
                    vo.setSandApparentDensity09(sysSand09.getApparentDensity());
                    vo.setSandParticleSizeDistribution09(sysSand09.getParticleSizeDistribution());
                    Integer regionName09 = sysSand09.getRegionName();
                    if (regionName09 != null) {
                        Region region1 = regionMap.get(regionName09);
                        if (region1 != null) {
                            vo.setSandRegionNameStr09(region1.getFullName());
                        }
                    }

                }
            }


            //石粉
            vo.setAdmixtures(smp.getStonePowder());
            Integer stonePowderId = smp.getStonePowderId();
            if (stonePowderId != null) {
                SysOtherAdmixtures sysOtherAdmixtures = OtherAdmixturesMap.get(stonePowderId);
                if (sysOtherAdmixtures != null) {
                    vo.setAdmixturesModel(sysOtherAdmixtures.getModel());
                    vo.setAdmixturesFineness(sysOtherAdmixtures.getFineness());
                    vo.setAdmixturesMoistureContent(sysOtherAdmixtures.getMoistureContent());
                    vo.setAdmixturesActivityIndex28d(sysOtherAdmixtures.getActivityIndex28d());
                    Integer regionName09 = sysOtherAdmixtures.getRegionName();
                    if (regionName09 != null) {
                        Region region1 = regionMap.get(regionName09);
                        if (region1 != null) {
                            vo.setAdmixturesRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //矿粉
            vo.setMineralPowder(smp.getMineralPowder());
            Integer mineralPowderId = smp.getMineralPowderId();
            if (mineralPowderId != null) {
                SysMineralPowder sysMineralPowder = SysMineralPowderMap.get(mineralPowderId);
                if (sysMineralPowder != null) {
                    vo.setMineralModel(sysMineralPowder.getModel());
                    vo.setMineralSlagGrade(sysMineralPowder.getSlagGrade());
                    vo.setMineralFineness(sysMineralPowder.getFineness());
                    vo.setMineralMoistureContent(sysMineralPowder.getMoistureContent());
                    vo.setMineralActivityIndex28d(sysMineralPowder.getActivityIndex28d());

                    Integer regionName = sysMineralPowder.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setMineralRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //粉煤灰
            vo.setFlyash(smp.getFlyAsh());
            Integer flyAshId = smp.getFlyAshId();
            if (flyAshId != null) {
                SysFlyash sysFlyash = flyashMap.get(flyAshId);
                if (sysFlyash != null) {
                    vo.setFlyashGrade(sysFlyash.getGrade());
                    vo.setFlyashFactoryGrade(sysFlyash.getFactoryGrade());
                    vo.setFlyashFineness(sysFlyash.getFineness());
                    vo.setFlyashMoistureContent(sysFlyash.getMoistureContent());
                    vo.setFlyashActivityIndex28d(sysFlyash.getActivityIndex28d());

                    Integer regionName = sysFlyash.getRegionName();
                    if (regionName != null) {
                        Region region1 = regionMap.get(regionName);
                        if (region1 != null) {
                            vo.setFlyashRegionNameStr(region1.getFullName());
                        }
                    }

                }
            }


            //减水剂

            vo.setReducer(smp.getWaterReducer());
            Integer waterReducerId = smp.getWaterReducerId();
            if (waterReducerId != null) {
                SysWaterReducer sysWaterReducer = SysWaterReducerMap.get(waterReducerId);
                if (sysWaterReducer != null) {
                    vo.setReducerModel(sysWaterReducer.getModel());
                    vo.setReducerSolidContent(sysWaterReducer.getSolidContent());
                    vo.setReducerCementPsteFlow(sysWaterReducer.getCementPasteFlow());
                    vo.setReducerReducingRate(sysWaterReducer.getReducingRate());
                    vo.setReducerRegionNameStr(sysWaterReducer.getSourceName());

                }
            }


            //增效剂
            vo.setEfficiencyAgentAgent(smp.getEfficiencyAgent());
            Integer efficiencyAgentId = smp.getEfficiencyAgentId();
            if (efficiencyAgentId != null) {
                SysEfficiencyAgent efficiencyAgent = efficiencyAgentMap.get(efficiencyAgentId);
                if (efficiencyAgent != null) {
                    vo.setEfficiencyAgentModel(efficiencyAgent.getModel());
                    vo.setEfficiencyAgentSourceName(efficiencyAgent.getSourceName());
                }
            }


            //膨胀剂
            vo.setSwellingAgent(smp.getExpansionAgent());
            Integer swellingAgentId = smp.getExpansionAgentId();
            if (swellingAgentId != null) {
                SysSwellingagent sysSwellingagent = swellingagentMap.get(swellingAgentId);
                if (sysSwellingagent != null) {
                    vo.setSwellingagentModel(sysSwellingagent.getModel());
                    vo.setSwellingagentSourceName(sysSwellingagent.getSourceName());

                }
            }


            agentVOList.add(vo);
        }
        String excelName = rawMaterialsDTO.getExcelName();
        // 生成 Excel 文件并保存到本地
        String filePath = saveExcelToLocalSlump(agentVOList, excelName);

        // 返回文件的 URL
        // 返回 AjaxResult，可以包含文件的 URL
        return AjaxResult.success("文件已生成", filePath);
    }

    // 保存 Excel 文件到本地
    private String saveExcelToLocalSlump(List<SysMechanicalPerformanceFourthVO> agentVOList, String excelName) {
        // 创建 Excel 工具类
        ExcelUtil<SysMechanicalPerformanceFourthVO> util = new ExcelUtil<>(SysMechanicalPerformanceFourthVO.class);


        UUID uuid = UUID.randomUUID();
        int hash = Math.abs(uuid.hashCode()); // 获取 hashCode 并取正数
        int sevenDigitNumber = hash % 10000000; // 取模确保是7位数字以内
        String number = String.format("%07d", sevenDigitNumber); // 补0凑足7位
        // 生成一个唯一的文件名，可以包含时间戳或其他方式
        String fileName = System.currentTimeMillis() + "_" + number + ".xlsx";

        // 设置文件保存路径（这里假设文件存储在服务器的 /uploads/ 文件夹中）
        // String filePath = "C:\\Users\\Administrator\\Desktop\\测试\\excel\\" + fileName;
        String filePath = mechanicalPerformanceExcelPath + fileName;
        // 创建目录（如果不存在）
        File dir = new File(mechanicalPerformanceExcelPath);
        if (!dir.exists()) {
            boolean created = dir.mkdirs(); // 创建目录（支持多级）
            if (created) {
                System.out.println("目录已创建: " + dir.getAbsolutePath());
            } else {
                System.out.println("目录创建失败！");
            }
        }


        ExcelFileHistory excelFileHistory = new ExcelFileHistory();
        excelFileHistory.setFileName(excelName);
        excelFileHistory.setFilePath(filePath);
        excelFileHistory.setCreateTime(LocalDateTime.now());
        excelFileHistory.setDeleteTime(0);
        excelFileHistory.setVersion(0);
        excelFileHistory.setType(1);//坍落度
        excelFileHistory.setUserId(SecurityUtils.getUserId());
        excelFileHistoryService.save(excelFileHistory);


//        SysExcelAudit sysExcelAudit = new SysExcelAudit();
//
//        sysExcelAudit.setTableName(excelName);
//        sysExcelAudit.setExcelPath(filePath);
//        sysExcelAudit.setCreateTime(LocalDateTime.now());
//        sysExcelAudit.setDeleteTime(0);
//        sysExcelAudit.setVersion(0);
//        sysExcelAudit.setType(1);//坍落度
//
//        sysExcelAuditService.save(sysExcelAudit);


        try {
            // 将数据导出到本地文件
            util.exportExcelToLocal(agentVOList, filePath);
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("导出文件失败", e);
        }

        return filePath;
    }

    private String saveExcelToLocalSlumpV2(List<SysMechanicalPerformanceFourthVO> agentVOList, String excelName) {
        // 创建 Excel 工具类
        ExcelUtil<SysMechanicalPerformanceFourthVO> util = new ExcelUtil<>(SysMechanicalPerformanceFourthVO.class);


        UUID uuid = UUID.randomUUID();
        int hash = Math.abs(uuid.hashCode()); // 获取 hashCode 并取正数
        int sevenDigitNumber = hash % 10000000; // 取模确保是7位数字以内
        String number = String.format("%07d", sevenDigitNumber); // 补0凑足7位
        // 生成一个唯一的文件名，可以包含时间戳或其他方式
        String fileName = System.currentTimeMillis() + "_" + number + ".xlsx";

        // 设置文件保存路径（这里假设文件存储在服务器的 /uploads/ 文件夹中）
        // String filePath = "C:\\Users\\Administrator\\Desktop\\测试\\excel\\" + fileName;
        String filePath = mechanicalPerformanceExcelPath + fileName;
        // 创建目录（如果不存在）
        File dir = new File(mechanicalPerformanceExcelPath);
        if (!dir.exists()) {
            boolean created = dir.mkdirs(); // 创建目录（支持多级）
            if (created) {
                System.out.println("目录已创建: " + dir.getAbsolutePath());
            } else {
                System.out.println("目录创建失败！");
            }
        }


/*        ExcelFileHistory excelFileHistory = new ExcelFileHistory();
        excelFileHistory.setFileName(excelName);
        excelFileHistory.setFilePath(filePath);
        excelFileHistory.setCreateTime(LocalDateTime.now());
        excelFileHistory.setDeleteTime(0);
        excelFileHistory.setVersion(0);
        excelFileHistory.setType(1);//坍落度
        excelFileHistory.setUserId(SecurityUtils.getUserId());
        excelFileHistoryService.save(excelFileHistory);*/


//        SysExcelAudit sysExcelAudit = new SysExcelAudit();
//
//        sysExcelAudit.setTableName(excelName);
//        sysExcelAudit.setExcelPath(filePath);
//        sysExcelAudit.setCreateTime(LocalDateTime.now());
//        sysExcelAudit.setDeleteTime(0);
//        sysExcelAudit.setVersion(0);
//        sysExcelAudit.setType(1);//坍落度
//
//        sysExcelAuditService.save(sysExcelAudit);


        try {
            // 将数据导出到本地文件
            util.exportExcelToLocal(agentVOList, filePath);
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("导出文件失败", e);
        }

        return filePath;
    }



@Autowired
private  SysMaterialSlumpUrlService sysMaterialSlumpUrlService;
    
    
    
    @PostMapping("queryTotalExportUrl")
    public AjaxResult queryTotalExportUrl() {
        List<SysMaterialSlumpUrl> list = sysMaterialSlumpUrlService.list();

        SysMaterialSlumpUrl sysMaterialSlumpUrl0 = list.get(0);
        SysMaterialSlumpUrl sysMaterilSlumpUrl1 = list.get(1);

        // 检查slumpUrl和compressiveStrengthUrl是否都不为空
        if (sysMaterilSlumpUrl1.getSlumpUrl() != null && sysMaterialSlumpUrl0.getMechanicalPerformanceUrl() != null) {
            HashMap<String, String> map = new HashMap<>();
            map.put("compressiveStrength", sysMaterialSlumpUrl0.getMechanicalPerformanceUrl());
            map.put("slump", sysMaterilSlumpUrl1.getSlumpUrl());
            return AjaxResult.success(map);
        }


        List<Integer> type = Arrays.asList(0, 1);
        HashMap<String, String> map = new HashMap<>();
        if (type.contains(0)) {

            // 查询膨胀剂数据
            List<SysMechanicalPerformance> agentList = sysMechanicalPerformanceService.list();

            // 获取地区信息，转换成 Map 以便后续使用
            List<Region> listRegion = regionService.list();
            Map<Integer, Region> regionMap = listRegion.stream()
                    .collect(Collectors.toMap(Region::getId, Function.identity()));


            // 获取水泥信息，转换成 Map 以便后续使用
            List<SysCement> listCement = sysCementService.list();
            Map<Integer, SysCement> CementMap = listCement.stream()
                    .collect(Collectors.toMap(SysCement::getCementId, Function.identity()));


            // 获取水泥信息，转换成 Map 以便后续使用
            List<SysStone> listStone = sysStoneService.list();
            Map<Integer, SysStone> StoneMap = listStone.stream()
                    .collect(Collectors.toMap(SysStone::getStoneId, Function.identity()));


            // 获取砂信息，转换成 Map 以便后续使用
            List<SysSand> listSande = sysSandService.list();
            Map<Integer, SysSand> SandeMap = listSande.stream()
                    .collect(Collectors.toMap(SysSand::getSandId, Function.identity()));


            // 获取石粉信息，转换成 Map 以便后续使用
            List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();
            Map<Integer, SysOtherAdmixtures> OtherAdmixturesMap = listOtherAdmixtures.stream()
                    .collect(Collectors.toMap(SysOtherAdmixtures::getAdmixturesId, Function.identity()));


            // 获取矿粉信息，转换成 Map 以便后续使用
            List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
            Map<Integer, SysMineralPowder> SysMineralPowderMap = listMineralPowder.stream()
                    .collect(Collectors.toMap(SysMineralPowder::getPowderId, Function.identity()));

            // 获取粉煤灰信息，转换成 Map 以便后续使用
            List<SysFlyash> listFlyash = sysFlyashService.list();
            Map<Integer, SysFlyash> flyashMap = listFlyash.stream()
                    .collect(Collectors.toMap(SysFlyash::getFlyashId, Function.identity()));


            // 获取减水剂信息，转换成 Map 以便后续使用
            List<SysWaterReducer> listSysWaterReducer = sysWaterReducerService.list();
            Map<Integer, SysWaterReducer> SysWaterReducerMap = listSysWaterReducer.stream()
                    .collect(Collectors.toMap(SysWaterReducer::getReducerId, Function.identity()));


            // 获取增效剂信息，转换成 Map 以便后续使用
            List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
            Map<Integer, SysEfficiencyAgent> efficiencyAgentMap = listEfficiencyAgent.stream()
                    .collect(Collectors.toMap(SysEfficiencyAgent::getAgentId, Function.identity()));


            // 获取增效剂信息，转换成 Map 以便后续使用
            List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
            Map<Integer, SysSwellingagent> swellingagentMap = listSwellingagent.stream()
                    .collect(Collectors.toMap(SysSwellingagent::getSwellingagentId, Function.identity()));

            // 准备返回的 VO 列表
            List<SysMechanicalPerformanceThirdVO> agentVOList = new ArrayList<>();
            for (SysMechanicalPerformance smp : agentList) {
                SysMechanicalPerformanceThirdVO vo = new SysMechanicalPerformanceThirdVO();
                BeanUtils.copyProperties(smp, vo);

                // 设置地区名称
                Integer regionId = smp.getRegion();
                Region region = regionMap.get(regionId);
                if (region != null) {
                    vo.setRegionNameStr(region.getFullName());
                }

                LocalDateTime productionDate = smp.getProductionDate();
                if (productionDate != null) {
                    vo.setProductionDate(productionDate);
                }


                //查询水泥数据
                Integer cementId = smp.getCementId();
                if (cementId != null) {
                    SysCement sysCement = CementMap.get(cementId);
                    if (sysCement != null) {
                        vo.setCementModel(sysCement.getModel());
                        vo.setCementCaoContent(sysCement.getCaoContent());
                        vo.setCementSio2Content(sysCement.getSio2Content());
                        vo.setCementAl2o3Content(sysCement.getAl2o3Content());
                        vo.setCementCompressiveStrength28d(sysCement.getCompressiveStrength28d());
                        vo.setCementStrengthGrade(sysCement.getStrengthGrade());
                        Integer regionName = sysCement.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setCementRegionNameStr(region1.getFullName());
                            }

                        }
                    }


                }


                //石头 5-10
                Integer stone510Id = smp.getStone510Id();
                if (stone510Id != null) {
                    SysStone sysStone510 = StoneMap.get(stone510Id);
                    if (sysStone510 != null) {
                        System.out.println("哈哈哈510" + sysStone510);
                        vo.setStoneModel510(sysStone510.getModel());
                        vo.setStoneSpecification510(sysStone510.getStoneSpecification());
                        vo.setStoneStackingDensity510(sysStone510.getStackingDensity());
                        vo.setStoneCompactDensity510(sysStone510.getCompactDensity());
                        vo.setStoneBulkdensity510(sysStone510.getBulkDensity());
                        Integer regionNameStone510 = sysStone510.getRegionName();
                        if (regionNameStone510 != null) {
                            Region region1 = regionMap.get(regionNameStone510);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr510(region1.getFullName());
                            }
                        }
                    }

                }

                //石头 5-25
                Integer stone525Id = smp.getStone525Id();
                if (stone525Id != null) {
                    SysStone sysStone525 = StoneMap.get(stone525Id);
                    if (sysStone525 != null) {
                        System.out.println("哈哈哈510" + sysStone525);
                        vo.setStoneModel525(sysStone525.getModel());
                        vo.setStoneSpecification525(sysStone525.getStoneSpecification());
                        vo.setStoneStackingDensity525(sysStone525.getStackingDensity());
                        vo.setStoneCompactDensity525(sysStone525.getCompactDensity());
                        vo.setStoneBulkdensity525(sysStone525.getBulkDensity());
                        Integer regionNameStone525 = sysStone525.getRegionName();
                        if (regionNameStone525 != null) {
                            Region region1 = regionMap.get(regionNameStone525);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr525(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 2040
                Integer stone2040Id = smp.getStone525Id();
                if (stone2040Id != null) {
                    SysStone sysStone2040 = StoneMap.get(stone2040Id);
                    if (sysStone2040 != null) {
                        System.out.println("哈哈哈510" + sysStone2040);
                        vo.setStoneModel2040(sysStone2040.getModel());
                        vo.setStoneSpecification2040(sysStone2040.getStoneSpecification());
                        vo.setStoneStackingDensity2040(sysStone2040.getStackingDensity());
                        vo.setStoneCompactDensity2040(sysStone2040.getCompactDensity());
                        vo.setStoneBulkdensity2040(sysStone2040.getBulkDensity());
                        Integer regionNameStone2040 = sysStone2040.getRegionName();
                        if (regionNameStone2040 != null) {
                            Region region1 = regionMap.get(regionNameStone2040);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr2040(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 10-20
                Integer stone1020Id = smp.getStone1020Id();
                if (stone1020Id != null) {
                    SysStone sysStone1020 = StoneMap.get(stone1020Id);
                    if (sysStone1020 != null) {
                        System.out.println("哈哈哈510" + sysStone1020);
                        vo.setStoneModel1020(sysStone1020.getModel());
                        vo.setStoneSpecification1020(sysStone1020.getStoneSpecification());
                        vo.setStoneStackingDensity1020(sysStone1020.getStackingDensity());
                        vo.setStoneCompactDensity1020(sysStone1020.getCompactDensity());
                        vo.setStoneBulkdensity1020(sysStone1020.getBulkDensity());
                        Integer regionNameStone1020 = sysStone1020.getRegionName();
                        if (regionNameStone1020 != null) {
                            Region region1 = regionMap.get(regionNameStone1020);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr1020(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 10-30
                Integer stone1030Id = smp.getStone1030Id();
                if (stone1030Id != null) {
                    SysStone sysStone1030 = StoneMap.get(stone1030Id);
                    if (sysStone1030 != null) {
                        System.out.println("哈哈哈510" + sysStone1030);
                        vo.setStoneModel1030(sysStone1030.getModel());
                        vo.setStoneSpecification1030(sysStone1030.getStoneSpecification());
                        vo.setStoneStackingDensity1030(sysStone1030.getStackingDensity());
                        vo.setStoneCompactDensity1030(sysStone1030.getCompactDensity());
                        vo.setStoneBulkdensity1030(sysStone1030.getBulkDensity());
                        Integer regionNameStone1030 = sysStone1030.getRegionName();
                        if (regionNameStone1030 != null) {
                            Region region1 = regionMap.get(regionNameStone1030);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr1030(region1.getFullName());
                            }
                        }
                    }
                }

                vo.setStone2031(smp.getStoneCoarse20315());
                //石头 0-10
                Integer stone010Id = smp.getStone010Id();
                if (stone010Id != null) {
                    SysStone sysStone010 = StoneMap.get(stone010Id);
                    if (sysStone010 != null) {

                        vo.setStoneModel010(sysStone010.getModel());
                        vo.setStoneSpecification010(sysStone010.getStoneSpecification());
                        vo.setStoneStackingDensity010(sysStone010.getStackingDensity());
                        vo.setStoneCompactDensity010(sysStone010.getCompactDensity());
                        vo.setStoneBulkdensity010(sysStone010.getBulkDensity());
                        Integer regionNameStone010 = sysStone010.getRegionName();
                        if (regionNameStone010 != null) {
                            Region region1 = regionMap.get(regionNameStone010);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr010(region1.getFullName());
                            }
                        }
                    }
                }

                //石头 20-315
                Integer stone20315Id = smp.getStone2031Id();
                if (stone20315Id != null) {
                    SysStone sysStone20315 = StoneMap.get(stone20315Id);
                    if (sysStone20315 != null) {

                        vo.setStoneModel20315(sysStone20315.getModel());
                        vo.setStoneSpecification20315(sysStone20315.getStoneSpecification());
                        vo.setStoneStackingDensity20315(sysStone20315.getStackingDensity());
                        vo.setStoneCompactDensity20315(sysStone20315.getCompactDensity());
                        vo.setStoneBulkdensity20315(sysStone20315.getBulkDensity());
                        Integer regionNameStone20315 = sysStone20315.getRegionName();
                        if (regionNameStone20315 != null) {
                            Region region1 = regionMap.get(regionNameStone20315);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr20315(region1.getFullName());
                            }
                        }
                    }
                }


                //砂31-37
                vo.setSand3137(smp.getSandRiverCoarse3137());
                Integer sandRiverCoarse3137Id = smp.getSandRiverCoarse3137Id();
                if (sandRiverCoarse3137Id != null) {
                    SysSand sysSand3137 = SandeMap.get(sandRiverCoarse3137Id);
                    if (sysSand3137 != null) {
                        vo.setSandType3137(sysSand3137.getType());
                        vo.setSandFineness3137(sysSand3137.getFineness());
                        vo.setSandBulkDensity3137(sysSand3137.getBulkDensity());
                        vo.setSandCompactDensity3137(sysSand3137.getCompactDensity());
                        vo.setSandApparentDensity3137(sysSand3137.getApparentDensity());
                        vo.setSandParticleSizeDistribution3137(sysSand3137.getParticleSizeDistribution());
                        Integer regionName3137 = sysSand3137.getRegionName();
                        if (regionName3137 != null) {
                            Region region1 = regionMap.get(regionName3137);
                            if (region1 != null) {
                                vo.setSandRegionNameStr3137(region1.getFullName());
                            }
                        }


                    }


                }


                //砂23-30
                vo.setSand2330(smp.getSandRiver2330Med());
                Integer sandRiverCoarse2330Id = smp.getSandRiver2330MedId();
                if (sandRiverCoarse2330Id != null) {
                    SysSand sysSand2330 = SandeMap.get(sandRiverCoarse2330Id);
                    if (sysSand2330 != null) {
                        vo.setSandType2330(sysSand2330.getType());
                        vo.setSandFineness2330(sysSand2330.getFineness());
                        vo.setSandBulkDensity2330(sysSand2330.getBulkDensity());
                        vo.setSandCompactDensity2330(sysSand2330.getCompactDensity());
                        vo.setSandApparentDensity2330(sysSand2330.getApparentDensity());
                        vo.setSandParticleSizeDistribution2330(sysSand2330.getParticleSizeDistribution());
                        Integer regionName2330 = sysSand2330.getRegionName();
                        if (regionName2330 != null) {
                            Region region1 = regionMap.get(regionName2330);
                            if (region1 != null) {
                                vo.setSandRegionNameStr2330(region1.getFullName());
                            }
                        }


                    }


                }


                //砂16-22
                vo.setSand1622(smp.getSandRiver1622Fine());
                Integer sandRiverCoarse1622Id = smp.getSandRiver1622FineId();
                if (sandRiverCoarse1622Id != null) {
                    SysSand sysSand1622 = SandeMap.get(sandRiverCoarse1622Id);
                    if (sysSand1622 != null) {
                        vo.setSandType1622(sysSand1622.getType());
                        vo.setSandFineness1622(sysSand1622.getFineness());
                        vo.setSandBulkDensity1622(sysSand1622.getBulkDensity());
                        vo.setSandCompactDensity1622(sysSand1622.getCompactDensity());
                        vo.setSandApparentDensity1622(sysSand1622.getApparentDensity());
                        vo.setSandParticleSizeDistribution1622(sysSand1622.getParticleSizeDistribution());
                        Integer regionName1622 = sysSand1622.getRegionName();
                        if (regionName1622 != null) {
                            Region region1 = regionMap.get(regionName1622);
                            if (region1 != null) {
                                vo.setSandRegionNameStr1622(region1.getFullName());
                            }
                        }

                    }

                }


                //砂2330B
                vo.setSand2330B(smp.getSandMech2330Med());
                Integer sandRiverCoarse2330BId = smp.getSandMech2330MedId();
                if (sandRiverCoarse2330BId != null) {
                    SysSand sysSand2330B = SandeMap.get(sandRiverCoarse2330BId);
                    if (sysSand2330B != null) {
                        vo.setSandType2330B(sysSand2330B.getType());
                        vo.setSandFineness2330B(sysSand2330B.getFineness());
                        vo.setSandBulkDensity2330B(sysSand2330B.getBulkDensity());
                        vo.setSandCompactDensity2330B(sysSand2330B.getCompactDensity());
                        vo.setSandApparentDensity2330B(sysSand2330B.getApparentDensity());
                        vo.setSandParticleSizeDistribution2330B(sysSand2330B.getParticleSizeDistribution());
                        Integer regionName2330B = sysSand2330B.getRegionName();
                        if (regionName2330B != null) {
                            Region region1 = regionMap.get(regionName2330B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr2330B(region1.getFullName());
                            }
                        }

                    }

                }


                //砂31-37B
                vo.setSand3137B(smp.getSandMech3137Coarse());
                Integer sandRiverCoarse3137BId = smp.getSandMech3137CoarseId();
                if (sandRiverCoarse3137BId != null) {
                    SysSand sysSand3137B = SandeMap.get(sandRiverCoarse3137BId);
                    if (sysSand3137B != null) {
                        vo.setSandType3137B(sysSand3137B.getType());
                        vo.setSandFineness3137B(sysSand3137B.getFineness());
                        vo.setSandBulkDensity3137B(sysSand3137B.getBulkDensity());
                        vo.setSandCompactDensity3137B(sysSand3137B.getCompactDensity());
                        vo.setSandApparentDensity3137B(sysSand3137B.getApparentDensity());
                        vo.setSandParticleSizeDistribution3137B(sysSand3137B.getParticleSizeDistribution());
                        Integer regionName3137B = sysSand3137B.getRegionName();
                        if (regionName3137B != null) {
                            Region region1 = regionMap.get(regionName3137B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr3137B(region1.getFullName());
                            }
                        }

                    }
                }


                //砂16-22
                vo.setSand1622B(smp.getSandMech1622Fine());
                Integer sandRiverCoarse1622BId = smp.getSandMech1622FineId();
                if (sandRiverCoarse1622BId != null) {
                    SysSand sysSand1622B = SandeMap.get(sandRiverCoarse1622BId);
                    if (sysSand1622B != null) {
                        vo.setSandType1622B(sysSand1622B.getType());
                        vo.setSandFineness1622B(sysSand1622B.getFineness());
                        vo.setSandBulkDensity1622B(sysSand1622B.getBulkDensity());
                        vo.setSandCompactDensity1622B(sysSand1622B.getCompactDensity());
                        vo.setSandApparentDensity1622B(sysSand1622B.getApparentDensity());
                        vo.setSandParticleSizeDistribution1622B(sysSand1622B.getParticleSizeDistribution());
                        Integer regionName1622B = sysSand1622B.getRegionName();
                        if (regionName1622B != null) {
                            Region region1 = regionMap.get(regionName1622B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr1622B(region1.getFullName());
                            }
                        }

                    }

                }


                //砂04-75
                vo.setSand0475(smp.getSandMech0475());
                Integer sandRiverCoarse0475Id = smp.getSandMech0475Id();
                if (sandRiverCoarse0475Id != null) {
                    SysSand sysSand0475 = SandeMap.get(sandRiverCoarse0475Id);
                    if (sysSand0475 != null) {
                        vo.setSandType0475(sysSand0475.getType());
                        vo.setSandFineness0475(sysSand0475.getFineness());
                        vo.setSandBulkDensity0475(sysSand0475.getBulkDensity());
                        vo.setSandCompactDensity0475(sysSand0475.getCompactDensity());
                        vo.setSandApparentDensity0475(sysSand0475.getApparentDensity());
                        vo.setSandParticleSizeDistribution0475(sysSand0475.getParticleSizeDistribution());
                        Integer regionName0475 = sysSand0475.getRegionName();
                        if (regionName0475 != null) {
                            Region region1 = regionMap.get(regionName0475);
                            if (region1 != null) {
                                vo.setSandRegionNameStr0475(region1.getFullName());
                            }
                        }

                    }
                }

//砂0-9
                vo.setSand09(smp.getSandMech09());
                Integer sandRiverCoarse09Id = smp.getSandMech09Id();
                if (sandRiverCoarse09Id != null) {
                    SysSand sysSand09 = SandeMap.get(sandRiverCoarse09Id);
                    if (sysSand09 != null) {
                        vo.setSandType09(sysSand09.getType());
                        vo.setSandFineness09(sysSand09.getFineness());
                        vo.setSandBulkDensity09(sysSand09.getBulkDensity());
                        vo.setSandCompactDensity09(sysSand09.getCompactDensity());
                        vo.setSandApparentDensity09(sysSand09.getApparentDensity());
                        vo.setSandParticleSizeDistribution09(sysSand09.getParticleSizeDistribution());
                        Integer regionName09 = sysSand09.getRegionName();
                        if (regionName09 != null) {
                            Region region1 = regionMap.get(regionName09);
                            if (region1 != null) {
                                vo.setSandRegionNameStr09(region1.getFullName());
                            }
                        }

                    }
                }


                //石粉
                vo.setAdmixtures(smp.getStonePowder());
                Integer stonePowderId = smp.getStonePowderId();
                if (stonePowderId != null) {
                    SysOtherAdmixtures sysOtherAdmixtures = OtherAdmixturesMap.get(stonePowderId);
                    if (sysOtherAdmixtures != null) {
                        vo.setAdmixturesModel(sysOtherAdmixtures.getModel());
                        vo.setAdmixturesFineness(sysOtherAdmixtures.getFineness());
                        vo.setAdmixturesMoistureContent(sysOtherAdmixtures.getMoistureContent());
                        vo.setAdmixturesActivityIndex28d(sysOtherAdmixtures.getActivityIndex28d());
                        Integer regionName09 = sysOtherAdmixtures.getRegionName();
                        if (regionName09 != null) {
                            Region region1 = regionMap.get(regionName09);
                            if (region1 != null) {
                                vo.setAdmixturesRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //矿粉
                vo.setMineralPowder(smp.getMineralPowder());
                Integer mineralPowderId = smp.getMineralPowderId();
                if (mineralPowderId != null) {
                    SysMineralPowder sysMineralPowder = SysMineralPowderMap.get(mineralPowderId);
                    if (sysMineralPowder != null) {
                        vo.setMineralModel(sysMineralPowder.getModel());
                        vo.setMineralSlagGrade(sysMineralPowder.getSlagGrade());
                        vo.setMineralFineness(sysMineralPowder.getFineness());
                        vo.setMineralMoistureContent(sysMineralPowder.getMoistureContent());
                        vo.setMineralActivityIndex28d(sysMineralPowder.getActivityIndex28d());

                        Integer regionName = sysMineralPowder.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setMineralRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //粉煤灰
                vo.setFlyash(smp.getFlyAsh());
                Integer flyAshId = smp.getFlyAshId();
                if (flyAshId != null) {
                    SysFlyash sysFlyash = flyashMap.get(flyAshId);
                    if (sysFlyash != null) {
                        vo.setFlyashGrade(sysFlyash.getGrade());
                        vo.setFlyashFactoryGrade(sysFlyash.getFactoryGrade());
                        vo.setFlyashFineness(sysFlyash.getFineness());
                        vo.setFlyashMoistureContent(sysFlyash.getMoistureContent());
                        vo.setFlyashActivityIndex28d(sysFlyash.getActivityIndex28d());

                        Integer regionName = sysFlyash.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setFlyashRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //减水剂

                vo.setReducer(smp.getWaterReducer());
                Integer waterReducerId = smp.getWaterReducerId();
                if (waterReducerId != null) {
                    SysWaterReducer sysWaterReducer = SysWaterReducerMap.get(waterReducerId);
                    if (sysWaterReducer != null) {
                        vo.setReducerModel(sysWaterReducer.getModel());
                        vo.setReducerSolidContent(sysWaterReducer.getSolidContent());
                        vo.setReducerCementPsteFlow(sysWaterReducer.getCementPasteFlow());
                        vo.setReducerReducingRate(sysWaterReducer.getReducingRate());
                        vo.setReducerRegionNameStr(sysWaterReducer.getSourceName());

                    }
                }


                //增效剂
                vo.setEfficiencyAgentAgent(smp.getEfficiencyAgent());
                Integer efficiencyAgentId = smp.getEfficiencyAgentId();
                if (efficiencyAgentId != null) {
                    SysEfficiencyAgent efficiencyAgent = efficiencyAgentMap.get(efficiencyAgentId);
                    if (efficiencyAgent != null) {
                        vo.setEfficiencyAgentModel(efficiencyAgent.getModel());
                        vo.setEfficiencyAgentSourceName(efficiencyAgent.getSourceName());
                    }
                }


                //膨胀剂
                vo.setSwellingAgent(smp.getExpansionAgent());
                Integer swellingAgentId = smp.getExpansionAgentId();
                if (swellingAgentId != null) {
                    SysSwellingagent sysSwellingagent = swellingagentMap.get(swellingAgentId);
                    if (sysSwellingagent != null) {
                        vo.setSwellingagentModel(sysSwellingagent.getModel());
                        vo.setSwellingagentSourceName(sysSwellingagent.getSourceName());

                    }
                }


                agentVOList.add(vo);
            }
            //String excelName = rawMaterialsDTO.getExcelName();
            // 生成 Excel 文件并保存到本地
            String filePath = saveExcelToLocalV2(agentVOList, "抗压强度");

            map.put("compressiveStrength",filePath);
            // 返回文件的 URL
            // 返回 AjaxResult，可以包含文件的 URL
            // return AjaxResult.success("文件已生成", filePath);


        }
        if (type.contains(1)){

            // 查询力学性能数据
            List<SysSlump> agentList = sysSlumpService.list();


            // 获取地区信息，转换成 Map 以便后续使用
            List<Region> listRegion = regionService.list();
            Map<Integer, Region> regionMap = listRegion.stream()
                    .collect(Collectors.toMap(Region::getId, Function.identity()));


            // 获取水泥信息，转换成 Map 以便后续使用
            List<SysCement> listCement = sysCementService.list();
            Map<Integer, SysCement> CementMap = listCement.stream()
                    .collect(Collectors.toMap(SysCement::getCementId, Function.identity()));


            // 获取水泥信息，转换成 Map 以便后续使用
            List<SysStone> listStone = sysStoneService.list();
            Map<Integer, SysStone> StoneMap = listStone.stream()
                    .collect(Collectors.toMap(SysStone::getStoneId, Function.identity()));


            // 获取砂信息，转换成 Map 以便后续使用
            List<SysSand> listSande = sysSandService.list();
            Map<Integer, SysSand> SandeMap = listSande.stream()
                    .collect(Collectors.toMap(SysSand::getSandId, Function.identity()));


            // 获取石粉信息，转换成 Map 以便后续使用
            List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();
            Map<Integer, SysOtherAdmixtures> OtherAdmixturesMap = listOtherAdmixtures.stream()
                    .collect(Collectors.toMap(SysOtherAdmixtures::getAdmixturesId, Function.identity()));


            // 获取矿粉信息，转换成 Map 以便后续使用
            List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
            Map<Integer, SysMineralPowder> SysMineralPowderMap = listMineralPowder.stream()
                    .collect(Collectors.toMap(SysMineralPowder::getPowderId, Function.identity()));

            // 获取粉煤灰信息，转换成 Map 以便后续使用
            List<SysFlyash> listFlyash = sysFlyashService.list();
            Map<Integer, SysFlyash> flyashMap = listFlyash.stream()
                    .collect(Collectors.toMap(SysFlyash::getFlyashId, Function.identity()));


            // 获取减水剂信息，转换成 Map 以便后续使用
            List<SysWaterReducer> listSysWaterReducer = sysWaterReducerService.list();
            Map<Integer, SysWaterReducer> SysWaterReducerMap = listSysWaterReducer.stream()
                    .collect(Collectors.toMap(SysWaterReducer::getReducerId, Function.identity()));


            // 获取增效剂信息，转换成 Map 以便后续使用
            List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
            Map<Integer, SysEfficiencyAgent> efficiencyAgentMap = listEfficiencyAgent.stream()
                    .collect(Collectors.toMap(SysEfficiencyAgent::getAgentId, Function.identity()));


            // 获取膨胀剂信息，转换成 Map 以便后续使用
            List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
            Map<Integer, SysSwellingagent> swellingagentMap = listSwellingagent.stream()
                    .collect(Collectors.toMap(SysSwellingagent::getSwellingagentId, Function.identity()));


            // 准备返回的 VO 列表
            List<SysMechanicalPerformanceFourthVO> agentVOList = new ArrayList<>();
            for (SysSlump smp : agentList) {
                SysMechanicalPerformanceFourthVO vo = new SysMechanicalPerformanceFourthVO();
                BeanUtils.copyProperties(smp, vo);

                // 设置地区名称
                Integer regionId = smp.getRegion();
                Region region = regionMap.get(regionId);
                if (region != null) {
                    vo.setRegionNameStr(region.getFullName());
                }

                LocalDateTime productionDate = smp.getProductionDate();
                if (productionDate != null) {
                    vo.setProductionDate(productionDate);
                }
                BigDecimal slump = smp.getSlump();
                vo.setStrengthGrade(slump);

                //查询水泥数据
                Integer cementId = smp.getCementId();
                if (cementId != null) {
                    SysCement sysCement = CementMap.get(cementId);
                    if (sysCement != null) {
                        vo.setCementModel(sysCement.getModel());
                        vo.setCementCaoContent(sysCement.getCaoContent());
                        vo.setCementSio2Content(sysCement.getSio2Content());
                        vo.setCementAl2o3Content(sysCement.getAl2o3Content());
                        vo.setCementCompressiveStrength28d(sysCement.getCompressiveStrength28d());
                        vo.setCementStrengthGrade(sysCement.getStrengthGrade());
                        Integer regionName = sysCement.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setCementRegionNameStr(region1.getFullName());
                            }

                        }
                    }


                }


                //石头 5-10
                Integer stone510Id = smp.getStone510Id();
                if (stone510Id != null) {
                    SysStone sysStone510 = StoneMap.get(stone510Id);
                    if (sysStone510 != null) {
                        System.out.println("哈哈哈510" + sysStone510);
                        vo.setStoneModel510(sysStone510.getModel());
                        vo.setStoneSpecification510(sysStone510.getStoneSpecification());
                        vo.setStoneStackingDensity510(sysStone510.getStackingDensity());
                        vo.setStoneCompactDensity510(sysStone510.getCompactDensity());
                        vo.setStoneBulkdensity510(sysStone510.getBulkDensity());
                        Integer regionNameStone510 = sysStone510.getRegionName();
                        if (regionNameStone510 != null) {
                            Region region1 = regionMap.get(regionNameStone510);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr510(region1.getFullName());
                            }
                        }
                    }

                }

                //石头 5-25
                Integer stone525Id = smp.getStone525Id();
                if (stone525Id != null) {
                    SysStone sysStone525 = StoneMap.get(stone525Id);
                    if (sysStone525 != null) {
                        System.out.println("哈哈哈510" + sysStone525);
                        vo.setStoneModel525(sysStone525.getModel());
                        vo.setStoneSpecification525(sysStone525.getStoneSpecification());
                        vo.setStoneStackingDensity525(sysStone525.getStackingDensity());
                        vo.setStoneCompactDensity525(sysStone525.getCompactDensity());
                        vo.setStoneBulkdensity525(sysStone525.getBulkDensity());
                        Integer regionNameStone525 = sysStone525.getRegionName();
                        if (regionNameStone525 != null) {
                            Region region1 = regionMap.get(regionNameStone525);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr525(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 2040
                Integer stone2040Id = smp.getStone525Id();
                if (stone2040Id != null) {
                    SysStone sysStone2040 = StoneMap.get(stone2040Id);
                    if (sysStone2040 != null) {
                        System.out.println("哈哈哈510" + sysStone2040);
                        vo.setStoneModel2040(sysStone2040.getModel());
                        vo.setStoneSpecification2040(sysStone2040.getStoneSpecification());
                        vo.setStoneStackingDensity2040(sysStone2040.getStackingDensity());
                        vo.setStoneCompactDensity2040(sysStone2040.getCompactDensity());
                        vo.setStoneBulkdensity2040(sysStone2040.getBulkDensity());
                        Integer regionNameStone2040 = sysStone2040.getRegionName();
                        if (regionNameStone2040 != null) {
                            Region region1 = regionMap.get(regionNameStone2040);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr2040(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 10-20
                Integer stone1020Id = smp.getStone1020Id();
                if (stone1020Id != null) {
                    SysStone sysStone1020 = StoneMap.get(stone1020Id);
                    if (sysStone1020 != null) {
                        System.out.println("哈哈哈510" + sysStone1020);
                        vo.setStoneModel1020(sysStone1020.getModel());
                        vo.setStoneSpecification1020(sysStone1020.getStoneSpecification());
                        vo.setStoneStackingDensity1020(sysStone1020.getStackingDensity());
                        vo.setStoneCompactDensity1020(sysStone1020.getCompactDensity());
                        vo.setStoneBulkdensity1020(sysStone1020.getBulkDensity());
                        Integer regionNameStone1020 = sysStone1020.getRegionName();
                        if (regionNameStone1020 != null) {
                            Region region1 = regionMap.get(regionNameStone1020);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr1020(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 10-30
                Integer stone1030Id = smp.getStone1030Id();
                if (stone1030Id != null) {
                    SysStone sysStone1030 = StoneMap.get(stone1030Id);
                    if (sysStone1030 != null) {
                        System.out.println("哈哈哈510" + sysStone1030);
                        vo.setStoneModel1030(sysStone1030.getModel());
                        vo.setStoneSpecification1030(sysStone1030.getStoneSpecification());
                        vo.setStoneStackingDensity1030(sysStone1030.getStackingDensity());
                        vo.setStoneCompactDensity1030(sysStone1030.getCompactDensity());
                        vo.setStoneBulkdensity1030(sysStone1030.getBulkDensity());
                        Integer regionNameStone1030 = sysStone1030.getRegionName();
                        if (regionNameStone1030 != null) {
                            Region region1 = regionMap.get(regionNameStone1030);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr1030(region1.getFullName());
                            }
                        }
                    }
                }

                vo.setStone2031(smp.getStoneCoarse20315());
                //石头 0-10
                Integer stone010Id = smp.getStone010Id();
                if (stone010Id != null) {
                    SysStone sysStone010 = StoneMap.get(stone010Id);
                    if (sysStone010 != null) {

                        vo.setStoneModel010(sysStone010.getModel());
                        vo.setStoneSpecification010(sysStone010.getStoneSpecification());
                        vo.setStoneStackingDensity010(sysStone010.getStackingDensity());
                        vo.setStoneCompactDensity010(sysStone010.getCompactDensity());
                        vo.setStoneBulkdensity010(sysStone010.getBulkDensity());
                        Integer regionNameStone010 = sysStone010.getRegionName();
                        if (regionNameStone010 != null) {
                            Region region1 = regionMap.get(regionNameStone010);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr010(region1.getFullName());
                            }
                        }
                    }
                }

                //石头 20-315
                Integer stone20315Id = smp.getStone2031Id();
                if (stone20315Id != null) {
                    SysStone sysStone20315 = StoneMap.get(stone20315Id);
                    if (sysStone20315 != null) {

                        vo.setStoneModel20315(sysStone20315.getModel());
                        vo.setStoneSpecification20315(sysStone20315.getStoneSpecification());
                        vo.setStoneStackingDensity20315(sysStone20315.getStackingDensity());
                        vo.setStoneCompactDensity20315(sysStone20315.getCompactDensity());
                        vo.setStoneBulkdensity20315(sysStone20315.getBulkDensity());
                        Integer regionNameStone20315 = sysStone20315.getRegionName();
                        if (regionNameStone20315 != null) {
                            Region region1 = regionMap.get(regionNameStone20315);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr20315(region1.getFullName());
                            }
                        }
                    }
                }


                //砂31-37
                vo.setSand3137(smp.getSandRiverCoarse3137());
                Integer sandRiverCoarse3137Id = smp.getSandRiverCoarse3137Id();
                if (sandRiverCoarse3137Id != null) {
                    SysSand sysSand3137 = SandeMap.get(sandRiverCoarse3137Id);
                    if (sysSand3137 != null) {
                        vo.setSandType3137(sysSand3137.getType());
                        vo.setSandFineness3137(sysSand3137.getFineness());
                        vo.setSandBulkDensity3137(sysSand3137.getBulkDensity());
                        vo.setSandCompactDensity3137(sysSand3137.getCompactDensity());
                        vo.setSandApparentDensity3137(sysSand3137.getApparentDensity());
                        vo.setSandParticleSizeDistribution3137(sysSand3137.getParticleSizeDistribution());
                        Integer regionName3137 = sysSand3137.getRegionName();
                        if (regionName3137 != null) {
                            Region region1 = regionMap.get(regionName3137);
                            if (region1 != null) {
                                vo.setSandRegionNameStr3137(region1.getFullName());
                            }
                        }


                    }


                }


                //砂23-30
                vo.setSand2330(smp.getSandRiver2330Med());
                Integer sandRiverCoarse2330Id = smp.getSandRiver2330MedId();
                if (sandRiverCoarse2330Id != null) {
                    SysSand sysSand2330 = SandeMap.get(sandRiverCoarse2330Id);
                    if (sysSand2330 != null) {
                        vo.setSandType2330(sysSand2330.getType());
                        vo.setSandFineness2330(sysSand2330.getFineness());
                        vo.setSandBulkDensity2330(sysSand2330.getBulkDensity());
                        vo.setSandCompactDensity2330(sysSand2330.getCompactDensity());
                        vo.setSandApparentDensity2330(sysSand2330.getApparentDensity());
                        vo.setSandParticleSizeDistribution2330(sysSand2330.getParticleSizeDistribution());
                        Integer regionName2330 = sysSand2330.getRegionName();
                        if (regionName2330 != null) {
                            Region region1 = regionMap.get(regionName2330);
                            if (region1 != null) {
                                vo.setSandRegionNameStr2330(region1.getFullName());
                            }
                        }


                    }


                }


                //砂16-22
                vo.setSand1622(smp.getSandRiver1622Fine());
                Integer sandRiverCoarse1622Id = smp.getSandRiver1622FineId();
                if (sandRiverCoarse1622Id != null) {
                    SysSand sysSand1622 = SandeMap.get(sandRiverCoarse1622Id);
                    if (sysSand1622 != null) {
                        vo.setSandType1622(sysSand1622.getType());
                        vo.setSandFineness1622(sysSand1622.getFineness());
                        vo.setSandBulkDensity1622(sysSand1622.getBulkDensity());
                        vo.setSandCompactDensity1622(sysSand1622.getCompactDensity());
                        vo.setSandApparentDensity1622(sysSand1622.getApparentDensity());
                        vo.setSandParticleSizeDistribution1622(sysSand1622.getParticleSizeDistribution());
                        Integer regionName1622 = sysSand1622.getRegionName();
                        if (regionName1622 != null) {
                            Region region1 = regionMap.get(regionName1622);
                            if (region1 != null) {
                                vo.setSandRegionNameStr1622(region1.getFullName());
                            }
                        }

                    }

                }


                //砂2330B
                vo.setSand2330B(smp.getSandMech2330Med());
                Integer sandRiverCoarse2330BId = smp.getSandMech2330MedId();
                if (sandRiverCoarse2330BId != null) {
                    SysSand sysSand2330B = SandeMap.get(sandRiverCoarse2330BId);
                    if (sysSand2330B != null) {
                        vo.setSandType2330B(sysSand2330B.getType());
                        vo.setSandFineness2330B(sysSand2330B.getFineness());
                        vo.setSandBulkDensity2330B(sysSand2330B.getBulkDensity());
                        vo.setSandCompactDensity2330B(sysSand2330B.getCompactDensity());
                        vo.setSandApparentDensity2330B(sysSand2330B.getApparentDensity());
                        vo.setSandParticleSizeDistribution2330B(sysSand2330B.getParticleSizeDistribution());
                        Integer regionName2330B = sysSand2330B.getRegionName();
                        if (regionName2330B != null) {
                            Region region1 = regionMap.get(regionName2330B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr2330B(region1.getFullName());
                            }
                        }

                    }

                }


                //砂31-37B
                vo.setSand3137B(smp.getSandMech3137Coarse());
                Integer sandRiverCoarse3137BId = smp.getSandMech3137CoarseId();
                if (sandRiverCoarse3137BId != null) {
                    SysSand sysSand3137B = SandeMap.get(sandRiverCoarse3137BId);
                    if (sysSand3137B != null) {
                        vo.setSandType3137B(sysSand3137B.getType());
                        vo.setSandFineness3137B(sysSand3137B.getFineness());
                        vo.setSandBulkDensity3137B(sysSand3137B.getBulkDensity());
                        vo.setSandCompactDensity3137B(sysSand3137B.getCompactDensity());
                        vo.setSandApparentDensity3137B(sysSand3137B.getApparentDensity());
                        vo.setSandParticleSizeDistribution3137B(sysSand3137B.getParticleSizeDistribution());
                        Integer regionName3137B = sysSand3137B.getRegionName();
                        if (regionName3137B != null) {
                            Region region1 = regionMap.get(regionName3137B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr3137B(region1.getFullName());
                            }
                        }

                    }
                }


                //砂16-22
                vo.setSand1622B(smp.getSandMech1622Fine());
                Integer sandRiverCoarse1622BId = smp.getSandMech1622FineId();
                if (sandRiverCoarse1622BId != null) {
                    SysSand sysSand1622B = SandeMap.get(sandRiverCoarse1622BId);
                    if (sysSand1622B != null) {
                        vo.setSandType1622B(sysSand1622B.getType());
                        vo.setSandFineness1622B(sysSand1622B.getFineness());
                        vo.setSandBulkDensity1622B(sysSand1622B.getBulkDensity());
                        vo.setSandCompactDensity1622B(sysSand1622B.getCompactDensity());
                        vo.setSandApparentDensity1622B(sysSand1622B.getApparentDensity());
                        vo.setSandParticleSizeDistribution1622B(sysSand1622B.getParticleSizeDistribution());
                        Integer regionName1622B = sysSand1622B.getRegionName();
                        if (regionName1622B != null) {
                            Region region1 = regionMap.get(regionName1622B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr1622B(region1.getFullName());
                            }
                        }

                    }

                }


                //砂04-75
                vo.setSand0475(smp.getSandMech0475());
                Integer sandRiverCoarse0475Id = smp.getSandMech0475Id();
                if (sandRiverCoarse0475Id != null) {
                    SysSand sysSand0475 = SandeMap.get(sandRiverCoarse0475Id);
                    if (sysSand0475 != null) {
                        vo.setSandType0475(sysSand0475.getType());
                        vo.setSandFineness0475(sysSand0475.getFineness());
                        vo.setSandBulkDensity0475(sysSand0475.getBulkDensity());
                        vo.setSandCompactDensity0475(sysSand0475.getCompactDensity());
                        vo.setSandApparentDensity0475(sysSand0475.getApparentDensity());
                        vo.setSandParticleSizeDistribution0475(sysSand0475.getParticleSizeDistribution());
                        Integer regionName0475 = sysSand0475.getRegionName();
                        if (regionName0475 != null) {
                            Region region1 = regionMap.get(regionName0475);
                            if (region1 != null) {
                                vo.setSandRegionNameStr0475(region1.getFullName());
                            }
                        }

                    }
                }

//砂0-9
                vo.setSand09(smp.getSandMech09());
                Integer sandRiverCoarse09Id = smp.getSandMech09Id();
                if (sandRiverCoarse09Id != null) {
                    SysSand sysSand09 = SandeMap.get(sandRiverCoarse09Id);
                    if (sysSand09 != null) {
                        vo.setSandType09(sysSand09.getType());
                        vo.setSandFineness09(sysSand09.getFineness());
                        vo.setSandBulkDensity09(sysSand09.getBulkDensity());
                        vo.setSandCompactDensity09(sysSand09.getCompactDensity());
                        vo.setSandApparentDensity09(sysSand09.getApparentDensity());
                        vo.setSandParticleSizeDistribution09(sysSand09.getParticleSizeDistribution());
                        Integer regionName09 = sysSand09.getRegionName();
                        if (regionName09 != null) {
                            Region region1 = regionMap.get(regionName09);
                            if (region1 != null) {
                                vo.setSandRegionNameStr09(region1.getFullName());
                            }
                        }

                    }
                }


                //石粉
                vo.setAdmixtures(smp.getStonePowder());
                Integer stonePowderId = smp.getStonePowderId();
                if (stonePowderId != null) {
                    SysOtherAdmixtures sysOtherAdmixtures = OtherAdmixturesMap.get(stonePowderId);
                    if (sysOtherAdmixtures != null) {
                        vo.setAdmixturesModel(sysOtherAdmixtures.getModel());
                        vo.setAdmixturesFineness(sysOtherAdmixtures.getFineness());
                        vo.setAdmixturesMoistureContent(sysOtherAdmixtures.getMoistureContent());
                        vo.setAdmixturesActivityIndex28d(sysOtherAdmixtures.getActivityIndex28d());
                        Integer regionName09 = sysOtherAdmixtures.getRegionName();
                        if (regionName09 != null) {
                            Region region1 = regionMap.get(regionName09);
                            if (region1 != null) {
                                vo.setAdmixturesRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //矿粉
                vo.setMineralPowder(smp.getMineralPowder());
                Integer mineralPowderId = smp.getMineralPowderId();
                if (mineralPowderId != null) {
                    SysMineralPowder sysMineralPowder = SysMineralPowderMap.get(mineralPowderId);
                    if (sysMineralPowder != null) {
                        vo.setMineralModel(sysMineralPowder.getModel());
                        vo.setMineralSlagGrade(sysMineralPowder.getSlagGrade());
                        vo.setMineralFineness(sysMineralPowder.getFineness());
                        vo.setMineralMoistureContent(sysMineralPowder.getMoistureContent());
                        vo.setMineralActivityIndex28d(sysMineralPowder.getActivityIndex28d());

                        Integer regionName = sysMineralPowder.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setMineralRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //粉煤灰
                vo.setFlyash(smp.getFlyAsh());
                Integer flyAshId = smp.getFlyAshId();
                if (flyAshId != null) {
                    SysFlyash sysFlyash = flyashMap.get(flyAshId);
                    if (sysFlyash != null) {
                        vo.setFlyashGrade(sysFlyash.getGrade());
                        vo.setFlyashFactoryGrade(sysFlyash.getFactoryGrade());
                        vo.setFlyashFineness(sysFlyash.getFineness());
                        vo.setFlyashMoistureContent(sysFlyash.getMoistureContent());
                        vo.setFlyashActivityIndex28d(sysFlyash.getActivityIndex28d());

                        Integer regionName = sysFlyash.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setFlyashRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //减水剂

                vo.setReducer(smp.getWaterReducer());
                Integer waterReducerId = smp.getWaterReducerId();
                if (waterReducerId != null) {
                    SysWaterReducer sysWaterReducer = SysWaterReducerMap.get(waterReducerId);
                    if (sysWaterReducer != null) {
                        vo.setReducerModel(sysWaterReducer.getModel());
                        vo.setReducerSolidContent(sysWaterReducer.getSolidContent());
                        vo.setReducerCementPsteFlow(sysWaterReducer.getCementPasteFlow());
                        vo.setReducerReducingRate(sysWaterReducer.getReducingRate());
                        vo.setReducerRegionNameStr(sysWaterReducer.getSourceName());

                    }
                }


                //增效剂
                vo.setEfficiencyAgentAgent(smp.getEfficiencyAgent());
                Integer efficiencyAgentId = smp.getEfficiencyAgentId();
                if (efficiencyAgentId != null) {
                    SysEfficiencyAgent efficiencyAgent = efficiencyAgentMap.get(efficiencyAgentId);
                    if (efficiencyAgent != null) {
                        vo.setEfficiencyAgentModel(efficiencyAgent.getModel());
                        vo.setEfficiencyAgentSourceName(efficiencyAgent.getSourceName());
                    }
                }


                //膨胀剂
                vo.setSwellingAgent(smp.getExpansionAgent());
                Integer swellingAgentId = smp.getExpansionAgentId();
                if (swellingAgentId != null) {
                    SysSwellingagent sysSwellingagent = swellingagentMap.get(swellingAgentId);
                    if (sysSwellingagent != null) {
                        vo.setSwellingagentModel(sysSwellingagent.getModel());
                        vo.setSwellingagentSourceName(sysSwellingagent.getSourceName());

                    }
                }


                agentVOList.add(vo);
            }

            // 生成 Excel 文件并保存到本地
            String filePath2 = saveExcelToLocalSlumpV2(agentVOList, "坍落度");

            System.out.println(filePath2+"坍落度url");

            map.put("slump",filePath2);
            // 返回文件的 URL
            // 返回 AjaxResult，可以包含文件的 URL
            //    return AjaxResult.success("文件已生成", filePath);

        }
        System.out.println("返回数据map：" + map);

        return AjaxResult.success(map);
    }


    /**
     * 根据类型导出力性能和坍落度
     */
/*
    @PostMapping("queryTotalExportUrl")
    public AjaxResult queryTotalExportUrl() {
        List<Integer> type = Arrays.asList(0, 1);
        HashMap<String, String> map = new HashMap<>();
        if (type.contains(0)) {

           // 查询膨胀剂数据
            List<SysMechanicalPerformance> agentList = sysMechanicalPerformanceService.list();

            // 获取地区信息，转换成 Map 以便后续使用
            List<Region> listRegion = regionService.list();
            Map<Integer, Region> regionMap = listRegion.stream()
                    .collect(Collectors.toMap(Region::getId, Function.identity()));


            // 获取水泥信息，转换成 Map 以便后续使用
            List<SysCement> listCement = sysCementService.list();
            Map<Integer, SysCement> CementMap = listCement.stream()
                    .collect(Collectors.toMap(SysCement::getCementId, Function.identity()));


            // 获取水泥信息，转换成 Map 以便后续使用
            List<SysStone> listStone = sysStoneService.list();
            Map<Integer, SysStone> StoneMap = listStone.stream()
                    .collect(Collectors.toMap(SysStone::getStoneId, Function.identity()));


            // 获取砂信息，转换成 Map 以便后续使用
            List<SysSand> listSande = sysSandService.list();
            Map<Integer, SysSand> SandeMap = listSande.stream()
                    .collect(Collectors.toMap(SysSand::getSandId, Function.identity()));


            // 获取石粉信息，转换成 Map 以便后续使用
            List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();
            Map<Integer, SysOtherAdmixtures> OtherAdmixturesMap = listOtherAdmixtures.stream()
                    .collect(Collectors.toMap(SysOtherAdmixtures::getAdmixturesId, Function.identity()));


            // 获取矿粉信息，转换成 Map 以便后续使用
            List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
            Map<Integer, SysMineralPowder> SysMineralPowderMap = listMineralPowder.stream()
                    .collect(Collectors.toMap(SysMineralPowder::getPowderId, Function.identity()));

            // 获取粉煤灰信息，转换成 Map 以便后续使用
            List<SysFlyash> listFlyash = sysFlyashService.list();
            Map<Integer, SysFlyash> flyashMap = listFlyash.stream()
                    .collect(Collectors.toMap(SysFlyash::getFlyashId, Function.identity()));


            // 获取减水剂信息，转换成 Map 以便后续使用
            List<SysWaterReducer> listSysWaterReducer = sysWaterReducerService.list();
            Map<Integer, SysWaterReducer> SysWaterReducerMap = listSysWaterReducer.stream()
                    .collect(Collectors.toMap(SysWaterReducer::getReducerId, Function.identity()));


            // 获取增效剂信息，转换成 Map 以便后续使用
            List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
            Map<Integer, SysEfficiencyAgent> efficiencyAgentMap = listEfficiencyAgent.stream()
                    .collect(Collectors.toMap(SysEfficiencyAgent::getAgentId, Function.identity()));


            // 获取增效剂信息，转换成 Map 以便后续使用
            List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
            Map<Integer, SysSwellingagent> swellingagentMap = listSwellingagent.stream()
                    .collect(Collectors.toMap(SysSwellingagent::getSwellingagentId, Function.identity()));

            // 准备返回的 VO 列表
            List<SysMechanicalPerformanceThirdVO> agentVOList = new ArrayList<>();
            for (SysMechanicalPerformance smp : agentList) {
                SysMechanicalPerformanceThirdVO vo = new SysMechanicalPerformanceThirdVO();
                BeanUtils.copyProperties(smp, vo);

                // 设置地区名称
                Integer regionId = smp.getRegion();
                Region region = regionMap.get(regionId);
                if (region != null) {
                    vo.setRegionNameStr(region.getFullName());
                }

                LocalDateTime productionDate = smp.getProductionDate();
                if (productionDate != null) {
                    vo.setProductionDate(productionDate);
                }


                //查询水泥数据
                Integer cementId = smp.getCementId();
                if (cementId != null) {
                    SysCement sysCement = CementMap.get(cementId);
                    if (sysCement != null) {
                        vo.setCementModel(sysCement.getModel());
                        vo.setCementCaoContent(sysCement.getCaoContent());
                        vo.setCementSio2Content(sysCement.getSio2Content());
                        vo.setCementAl2o3Content(sysCement.getAl2o3Content());
                        vo.setCementCompressiveStrength28d(sysCement.getCompressiveStrength28d());
                        vo.setCementStrengthGrade(sysCement.getStrengthGrade());
                        Integer regionName = sysCement.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setCementRegionNameStr(region1.getFullName());
                            }

                        }
                    }


                }


                //石头 5-10
                Integer stone510Id = smp.getStone510Id();
                if (stone510Id != null) {
                    SysStone sysStone510 = StoneMap.get(stone510Id);
                    if (sysStone510 != null) {
                        System.out.println("哈哈哈510" + sysStone510);
                        vo.setStoneModel510(sysStone510.getModel());
                        vo.setStoneSpecification510(sysStone510.getStoneSpecification());
                        vo.setStoneStackingDensity510(sysStone510.getStackingDensity());
                        vo.setStoneCompactDensity510(sysStone510.getCompactDensity());
                        vo.setStoneBulkdensity510(sysStone510.getBulkDensity());
                        Integer regionNameStone510 = sysStone510.getRegionName();
                        if (regionNameStone510 != null) {
                            Region region1 = regionMap.get(regionNameStone510);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr510(region1.getFullName());
                            }
                        }
                    }

                }

                //石头 5-25
                Integer stone525Id = smp.getStone525Id();
                if (stone525Id != null) {
                    SysStone sysStone525 = StoneMap.get(stone525Id);
                    if (sysStone525 != null) {
                        System.out.println("哈哈哈510" + sysStone525);
                        vo.setStoneModel525(sysStone525.getModel());
                        vo.setStoneSpecification525(sysStone525.getStoneSpecification());
                        vo.setStoneStackingDensity525(sysStone525.getStackingDensity());
                        vo.setStoneCompactDensity525(sysStone525.getCompactDensity());
                        vo.setStoneBulkdensity525(sysStone525.getBulkDensity());
                        Integer regionNameStone525 = sysStone525.getRegionName();
                        if (regionNameStone525 != null) {
                            Region region1 = regionMap.get(regionNameStone525);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr525(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 2040
                Integer stone2040Id = smp.getStone525Id();
                if (stone2040Id != null) {
                    SysStone sysStone2040 = StoneMap.get(stone2040Id);
                    if (sysStone2040 != null) {
                        System.out.println("哈哈哈510" + sysStone2040);
                        vo.setStoneModel2040(sysStone2040.getModel());
                        vo.setStoneSpecification2040(sysStone2040.getStoneSpecification());
                        vo.setStoneStackingDensity2040(sysStone2040.getStackingDensity());
                        vo.setStoneCompactDensity2040(sysStone2040.getCompactDensity());
                        vo.setStoneBulkdensity2040(sysStone2040.getBulkDensity());
                        Integer regionNameStone2040 = sysStone2040.getRegionName();
                        if (regionNameStone2040 != null) {
                            Region region1 = regionMap.get(regionNameStone2040);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr2040(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 10-20
                Integer stone1020Id = smp.getStone1020Id();
                if (stone1020Id != null) {
                    SysStone sysStone1020 = StoneMap.get(stone1020Id);
                    if (sysStone1020 != null) {
                        System.out.println("哈哈哈510" + sysStone1020);
                        vo.setStoneModel1020(sysStone1020.getModel());
                        vo.setStoneSpecification1020(sysStone1020.getStoneSpecification());
                        vo.setStoneStackingDensity1020(sysStone1020.getStackingDensity());
                        vo.setStoneCompactDensity1020(sysStone1020.getCompactDensity());
                        vo.setStoneBulkdensity1020(sysStone1020.getBulkDensity());
                        Integer regionNameStone1020 = sysStone1020.getRegionName();
                        if (regionNameStone1020 != null) {
                            Region region1 = regionMap.get(regionNameStone1020);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr1020(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 10-30
                Integer stone1030Id = smp.getStone1030Id();
                if (stone1030Id != null) {
                    SysStone sysStone1030 = StoneMap.get(stone1030Id);
                    if (sysStone1030 != null) {
                        System.out.println("哈哈哈510" + sysStone1030);
                        vo.setStoneModel1030(sysStone1030.getModel());
                        vo.setStoneSpecification1030(sysStone1030.getStoneSpecification());
                        vo.setStoneStackingDensity1030(sysStone1030.getStackingDensity());
                        vo.setStoneCompactDensity1030(sysStone1030.getCompactDensity());
                        vo.setStoneBulkdensity1030(sysStone1030.getBulkDensity());
                        Integer regionNameStone1030 = sysStone1030.getRegionName();
                        if (regionNameStone1030 != null) {
                            Region region1 = regionMap.get(regionNameStone1030);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr1030(region1.getFullName());
                            }
                        }
                    }
                }

                vo.setStone2031(smp.getStoneCoarse20315());
                //石头 0-10
                Integer stone010Id = smp.getStone010Id();
                if (stone010Id != null) {
                    SysStone sysStone010 = StoneMap.get(stone010Id);
                    if (sysStone010 != null) {

                        vo.setStoneModel010(sysStone010.getModel());
                        vo.setStoneSpecification010(sysStone010.getStoneSpecification());
                        vo.setStoneStackingDensity010(sysStone010.getStackingDensity());
                        vo.setStoneCompactDensity010(sysStone010.getCompactDensity());
                        vo.setStoneBulkdensity010(sysStone010.getBulkDensity());
                        Integer regionNameStone010 = sysStone010.getRegionName();
                        if (regionNameStone010 != null) {
                            Region region1 = regionMap.get(regionNameStone010);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr010(region1.getFullName());
                            }
                        }
                    }
                }

                //石头 20-315
                Integer stone20315Id = smp.getStone2031Id();
                if (stone20315Id != null) {
                    SysStone sysStone20315 = StoneMap.get(stone20315Id);
                    if (sysStone20315 != null) {

                        vo.setStoneModel20315(sysStone20315.getModel());
                        vo.setStoneSpecification20315(sysStone20315.getStoneSpecification());
                        vo.setStoneStackingDensity20315(sysStone20315.getStackingDensity());
                        vo.setStoneCompactDensity20315(sysStone20315.getCompactDensity());
                        vo.setStoneBulkdensity20315(sysStone20315.getBulkDensity());
                        Integer regionNameStone20315 = sysStone20315.getRegionName();
                        if (regionNameStone20315 != null) {
                            Region region1 = regionMap.get(regionNameStone20315);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr20315(region1.getFullName());
                            }
                        }
                    }
                }


                //砂31-37
                vo.setSand3137(smp.getSandRiverCoarse3137());
                Integer sandRiverCoarse3137Id = smp.getSandRiverCoarse3137Id();
                if (sandRiverCoarse3137Id != null) {
                    SysSand sysSand3137 = SandeMap.get(sandRiverCoarse3137Id);
                    if (sysSand3137 != null) {
                        vo.setSandType3137(sysSand3137.getType());
                        vo.setSandFineness3137(sysSand3137.getFineness());
                        vo.setSandBulkDensity3137(sysSand3137.getBulkDensity());
                        vo.setSandCompactDensity3137(sysSand3137.getCompactDensity());
                        vo.setSandApparentDensity3137(sysSand3137.getApparentDensity());
                        vo.setSandParticleSizeDistribution3137(sysSand3137.getParticleSizeDistribution());
                        Integer regionName3137 = sysSand3137.getRegionName();
                        if (regionName3137 != null) {
                            Region region1 = regionMap.get(regionName3137);
                            if (region1 != null) {
                                vo.setSandRegionNameStr3137(region1.getFullName());
                            }
                        }


                    }


                }


                //砂23-30
                vo.setSand2330(smp.getSandRiver2330Med());
                Integer sandRiverCoarse2330Id = smp.getSandRiver2330MedId();
                if (sandRiverCoarse2330Id != null) {
                    SysSand sysSand2330 = SandeMap.get(sandRiverCoarse2330Id);
                    if (sysSand2330 != null) {
                        vo.setSandType2330(sysSand2330.getType());
                        vo.setSandFineness2330(sysSand2330.getFineness());
                        vo.setSandBulkDensity2330(sysSand2330.getBulkDensity());
                        vo.setSandCompactDensity2330(sysSand2330.getCompactDensity());
                        vo.setSandApparentDensity2330(sysSand2330.getApparentDensity());
                        vo.setSandParticleSizeDistribution2330(sysSand2330.getParticleSizeDistribution());
                        Integer regionName2330 = sysSand2330.getRegionName();
                        if (regionName2330 != null) {
                            Region region1 = regionMap.get(regionName2330);
                            if (region1 != null) {
                                vo.setSandRegionNameStr2330(region1.getFullName());
                            }
                        }


                    }


                }


                //砂16-22
                vo.setSand1622(smp.getSandRiver1622Fine());
                Integer sandRiverCoarse1622Id = smp.getSandRiver1622FineId();
                if (sandRiverCoarse1622Id != null) {
                    SysSand sysSand1622 = SandeMap.get(sandRiverCoarse1622Id);
                    if (sysSand1622 != null) {
                        vo.setSandType1622(sysSand1622.getType());
                        vo.setSandFineness1622(sysSand1622.getFineness());
                        vo.setSandBulkDensity1622(sysSand1622.getBulkDensity());
                        vo.setSandCompactDensity1622(sysSand1622.getCompactDensity());
                        vo.setSandApparentDensity1622(sysSand1622.getApparentDensity());
                        vo.setSandParticleSizeDistribution1622(sysSand1622.getParticleSizeDistribution());
                        Integer regionName1622 = sysSand1622.getRegionName();
                        if (regionName1622 != null) {
                            Region region1 = regionMap.get(regionName1622);
                            if (region1 != null) {
                                vo.setSandRegionNameStr1622(region1.getFullName());
                            }
                        }

                    }

                }


                //砂2330B
                vo.setSand2330B(smp.getSandMech2330Med());
                Integer sandRiverCoarse2330BId = smp.getSandMech2330MedId();
                if (sandRiverCoarse2330BId != null) {
                    SysSand sysSand2330B = SandeMap.get(sandRiverCoarse2330BId);
                    if (sysSand2330B != null) {
                        vo.setSandType2330B(sysSand2330B.getType());
                        vo.setSandFineness2330B(sysSand2330B.getFineness());
                        vo.setSandBulkDensity2330B(sysSand2330B.getBulkDensity());
                        vo.setSandCompactDensity2330B(sysSand2330B.getCompactDensity());
                        vo.setSandApparentDensity2330B(sysSand2330B.getApparentDensity());
                        vo.setSandParticleSizeDistribution2330B(sysSand2330B.getParticleSizeDistribution());
                        Integer regionName2330B = sysSand2330B.getRegionName();
                        if (regionName2330B != null) {
                            Region region1 = regionMap.get(regionName2330B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr2330B(region1.getFullName());
                            }
                        }

                    }

                }


                //砂31-37B
                vo.setSand3137B(smp.getSandMech3137Coarse());
                Integer sandRiverCoarse3137BId = smp.getSandMech3137CoarseId();
                if (sandRiverCoarse3137BId != null) {
                    SysSand sysSand3137B = SandeMap.get(sandRiverCoarse3137BId);
                    if (sysSand3137B != null) {
                        vo.setSandType3137B(sysSand3137B.getType());
                        vo.setSandFineness3137B(sysSand3137B.getFineness());
                        vo.setSandBulkDensity3137B(sysSand3137B.getBulkDensity());
                        vo.setSandCompactDensity3137B(sysSand3137B.getCompactDensity());
                        vo.setSandApparentDensity3137B(sysSand3137B.getApparentDensity());
                        vo.setSandParticleSizeDistribution3137B(sysSand3137B.getParticleSizeDistribution());
                        Integer regionName3137B = sysSand3137B.getRegionName();
                        if (regionName3137B != null) {
                            Region region1 = regionMap.get(regionName3137B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr3137B(region1.getFullName());
                            }
                        }

                    }
                }


                //砂16-22
                vo.setSand1622B(smp.getSandMech1622Fine());
                Integer sandRiverCoarse1622BId = smp.getSandMech1622FineId();
                if (sandRiverCoarse1622BId != null) {
                    SysSand sysSand1622B = SandeMap.get(sandRiverCoarse1622BId);
                    if (sysSand1622B != null) {
                        vo.setSandType1622B(sysSand1622B.getType());
                        vo.setSandFineness1622B(sysSand1622B.getFineness());
                        vo.setSandBulkDensity1622B(sysSand1622B.getBulkDensity());
                        vo.setSandCompactDensity1622B(sysSand1622B.getCompactDensity());
                        vo.setSandApparentDensity1622B(sysSand1622B.getApparentDensity());
                        vo.setSandParticleSizeDistribution1622B(sysSand1622B.getParticleSizeDistribution());
                        Integer regionName1622B = sysSand1622B.getRegionName();
                        if (regionName1622B != null) {
                            Region region1 = regionMap.get(regionName1622B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr1622B(region1.getFullName());
                            }
                        }

                    }

                }


                //砂04-75
                vo.setSand0475(smp.getSandMech0475());
                Integer sandRiverCoarse0475Id = smp.getSandMech0475Id();
                if (sandRiverCoarse0475Id != null) {
                    SysSand sysSand0475 = SandeMap.get(sandRiverCoarse0475Id);
                    if (sysSand0475 != null) {
                        vo.setSandType0475(sysSand0475.getType());
                        vo.setSandFineness0475(sysSand0475.getFineness());
                        vo.setSandBulkDensity0475(sysSand0475.getBulkDensity());
                        vo.setSandCompactDensity0475(sysSand0475.getCompactDensity());
                        vo.setSandApparentDensity0475(sysSand0475.getApparentDensity());
                        vo.setSandParticleSizeDistribution0475(sysSand0475.getParticleSizeDistribution());
                        Integer regionName0475 = sysSand0475.getRegionName();
                        if (regionName0475 != null) {
                            Region region1 = regionMap.get(regionName0475);
                            if (region1 != null) {
                                vo.setSandRegionNameStr0475(region1.getFullName());
                            }
                        }

                    }
                }

//砂0-9
                vo.setSand09(smp.getSandMech09());
                Integer sandRiverCoarse09Id = smp.getSandMech09Id();
                if (sandRiverCoarse09Id != null) {
                    SysSand sysSand09 = SandeMap.get(sandRiverCoarse09Id);
                    if (sysSand09 != null) {
                        vo.setSandType09(sysSand09.getType());
                        vo.setSandFineness09(sysSand09.getFineness());
                        vo.setSandBulkDensity09(sysSand09.getBulkDensity());
                        vo.setSandCompactDensity09(sysSand09.getCompactDensity());
                        vo.setSandApparentDensity09(sysSand09.getApparentDensity());
                        vo.setSandParticleSizeDistribution09(sysSand09.getParticleSizeDistribution());
                        Integer regionName09 = sysSand09.getRegionName();
                        if (regionName09 != null) {
                            Region region1 = regionMap.get(regionName09);
                            if (region1 != null) {
                                vo.setSandRegionNameStr09(region1.getFullName());
                            }
                        }

                    }
                }


                //石粉
                vo.setAdmixtures(smp.getStonePowder());
                Integer stonePowderId = smp.getStonePowderId();
                if (stonePowderId != null) {
                    SysOtherAdmixtures sysOtherAdmixtures = OtherAdmixturesMap.get(stonePowderId);
                    if (sysOtherAdmixtures != null) {
                        vo.setAdmixturesModel(sysOtherAdmixtures.getModel());
                        vo.setAdmixturesFineness(sysOtherAdmixtures.getFineness());
                        vo.setAdmixturesMoistureContent(sysOtherAdmixtures.getMoistureContent());
                        vo.setAdmixturesActivityIndex28d(sysOtherAdmixtures.getActivityIndex28d());
                        Integer regionName09 = sysOtherAdmixtures.getRegionName();
                        if (regionName09 != null) {
                            Region region1 = regionMap.get(regionName09);
                            if (region1 != null) {
                                vo.setAdmixturesRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //矿粉
                vo.setMineralPowder(smp.getMineralPowder());
                Integer mineralPowderId = smp.getMineralPowderId();
                if (mineralPowderId != null) {
                    SysMineralPowder sysMineralPowder = SysMineralPowderMap.get(mineralPowderId);
                    if (sysMineralPowder != null) {
                        vo.setMineralModel(sysMineralPowder.getModel());
                        vo.setMineralSlagGrade(sysMineralPowder.getSlagGrade());
                        vo.setMineralFineness(sysMineralPowder.getFineness());
                        vo.setMineralMoistureContent(sysMineralPowder.getMoistureContent());
                        vo.setMineralActivityIndex28d(sysMineralPowder.getActivityIndex28d());

                        Integer regionName = sysMineralPowder.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setMineralRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //粉煤灰
                vo.setFlyash(smp.getFlyAsh());
                Integer flyAshId = smp.getFlyAshId();
                if (flyAshId != null) {
                    SysFlyash sysFlyash = flyashMap.get(flyAshId);
                    if (sysFlyash != null) {
                        vo.setFlyashGrade(sysFlyash.getGrade());
                        vo.setFlyashFactoryGrade(sysFlyash.getFactoryGrade());
                        vo.setFlyashFineness(sysFlyash.getFineness());
                        vo.setFlyashMoistureContent(sysFlyash.getMoistureContent());
                        vo.setFlyashActivityIndex28d(sysFlyash.getActivityIndex28d());

                        Integer regionName = sysFlyash.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setFlyashRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //减水剂

                vo.setReducer(smp.getWaterReducer());
                Integer waterReducerId = smp.getWaterReducerId();
                if (waterReducerId != null) {
                    SysWaterReducer sysWaterReducer = SysWaterReducerMap.get(waterReducerId);
                    if (sysWaterReducer != null) {
                        vo.setReducerModel(sysWaterReducer.getModel());
                        vo.setReducerSolidContent(sysWaterReducer.getSolidContent());
                        vo.setReducerCementPsteFlow(sysWaterReducer.getCementPasteFlow());
                        vo.setReducerReducingRate(sysWaterReducer.getReducingRate());
                        vo.setReducerRegionNameStr(sysWaterReducer.getSourceName());

                    }
                }


                //增效剂
                vo.setEfficiencyAgentAgent(smp.getEfficiencyAgent());
                Integer efficiencyAgentId = smp.getEfficiencyAgentId();
                if (efficiencyAgentId != null) {
                    SysEfficiencyAgent efficiencyAgent = efficiencyAgentMap.get(efficiencyAgentId);
                    if (efficiencyAgent != null) {
                        vo.setEfficiencyAgentModel(efficiencyAgent.getModel());
                        vo.setEfficiencyAgentSourceName(efficiencyAgent.getSourceName());
                    }
                }


                //膨胀剂
                vo.setSwellingAgent(smp.getExpansionAgent());
                Integer swellingAgentId = smp.getExpansionAgentId();
                if (swellingAgentId != null) {
                    SysSwellingagent sysSwellingagent = swellingagentMap.get(swellingAgentId);
                    if (sysSwellingagent != null) {
                        vo.setSwellingagentModel(sysSwellingagent.getModel());
                        vo.setSwellingagentSourceName(sysSwellingagent.getSourceName());

                    }
                }


                agentVOList.add(vo);
            }
            //String excelName = rawMaterialsDTO.getExcelName();
            // 生成 Excel 文件并保存到本地
            String filePath = saveExcelToLocalV2(agentVOList, "抗压强度");

            map.put("compressiveStrength",filePath);
            // 返回文件的 URL
            // 返回 AjaxResult，可以包含文件的 URL
           // return AjaxResult.success("文件已生成", filePath);


        }
        if (type.contains(1)){

            // 查询力学性能数据
            List<SysSlump> agentList = sysSlumpService.list();


            // 获取地区信息，转换成 Map 以便后续使用
            List<Region> listRegion = regionService.list();
            Map<Integer, Region> regionMap = listRegion.stream()
                    .collect(Collectors.toMap(Region::getId, Function.identity()));


            // 获取水泥信息，转换成 Map 以便后续使用
            List<SysCement> listCement = sysCementService.list();
            Map<Integer, SysCement> CementMap = listCement.stream()
                    .collect(Collectors.toMap(SysCement::getCementId, Function.identity()));


            // 获取水泥信息，转换成 Map 以便后续使用
            List<SysStone> listStone = sysStoneService.list();
            Map<Integer, SysStone> StoneMap = listStone.stream()
                    .collect(Collectors.toMap(SysStone::getStoneId, Function.identity()));


            // 获取砂信息，转换成 Map 以便后续使用
            List<SysSand> listSande = sysSandService.list();
            Map<Integer, SysSand> SandeMap = listSande.stream()
                    .collect(Collectors.toMap(SysSand::getSandId, Function.identity()));


            // 获取石粉信息，转换成 Map 以便后续使用
            List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();
            Map<Integer, SysOtherAdmixtures> OtherAdmixturesMap = listOtherAdmixtures.stream()
                    .collect(Collectors.toMap(SysOtherAdmixtures::getAdmixturesId, Function.identity()));


            // 获取矿粉信息，转换成 Map 以便后续使用
            List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
            Map<Integer, SysMineralPowder> SysMineralPowderMap = listMineralPowder.stream()
                    .collect(Collectors.toMap(SysMineralPowder::getPowderId, Function.identity()));

            // 获取粉煤灰信息，转换成 Map 以便后续使用
            List<SysFlyash> listFlyash = sysFlyashService.list();
            Map<Integer, SysFlyash> flyashMap = listFlyash.stream()
                    .collect(Collectors.toMap(SysFlyash::getFlyashId, Function.identity()));


            // 获取减水剂信息，转换成 Map 以便后续使用
            List<SysWaterReducer> listSysWaterReducer = sysWaterReducerService.list();
            Map<Integer, SysWaterReducer> SysWaterReducerMap = listSysWaterReducer.stream()
                    .collect(Collectors.toMap(SysWaterReducer::getReducerId, Function.identity()));


            // 获取增效剂信息，转换成 Map 以便后续使用
            List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
            Map<Integer, SysEfficiencyAgent> efficiencyAgentMap = listEfficiencyAgent.stream()
                    .collect(Collectors.toMap(SysEfficiencyAgent::getAgentId, Function.identity()));


            // 获取膨胀剂信息，转换成 Map 以便后续使用
            List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
            Map<Integer, SysSwellingagent> swellingagentMap = listSwellingagent.stream()
                    .collect(Collectors.toMap(SysSwellingagent::getSwellingagentId, Function.identity()));


            // 准备返回的 VO 列表
            List<SysMechanicalPerformanceFourthVO> agentVOList = new ArrayList<>();
            for (SysSlump smp : agentList) {
                SysMechanicalPerformanceFourthVO vo = new SysMechanicalPerformanceFourthVO();
                BeanUtils.copyProperties(smp, vo);

                // 设置地区名称
                Integer regionId = smp.getRegion();
                Region region = regionMap.get(regionId);
                if (region != null) {
                    vo.setRegionNameStr(region.getFullName());
                }

                LocalDateTime productionDate = smp.getProductionDate();
                if (productionDate != null) {
                    vo.setProductionDate(productionDate);
                }
                BigDecimal slump = smp.getSlump();
                vo.setStrengthGrade(slump);

                //查询水泥数据
                Integer cementId = smp.getCementId();
                if (cementId != null) {
                    SysCement sysCement = CementMap.get(cementId);
                    if (sysCement != null) {
                        vo.setCementModel(sysCement.getModel());
                        vo.setCementCaoContent(sysCement.getCaoContent());
                        vo.setCementSio2Content(sysCement.getSio2Content());
                        vo.setCementAl2o3Content(sysCement.getAl2o3Content());
                        vo.setCementCompressiveStrength28d(sysCement.getCompressiveStrength28d());
                        vo.setCementStrengthGrade(sysCement.getStrengthGrade());
                        Integer regionName = sysCement.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setCementRegionNameStr(region1.getFullName());
                            }

                        }
                    }


                }


                //石头 5-10
                Integer stone510Id = smp.getStone510Id();
                if (stone510Id != null) {
                    SysStone sysStone510 = StoneMap.get(stone510Id);
                    if (sysStone510 != null) {
                        System.out.println("哈哈哈510" + sysStone510);
                        vo.setStoneModel510(sysStone510.getModel());
                        vo.setStoneSpecification510(sysStone510.getStoneSpecification());
                        vo.setStoneStackingDensity510(sysStone510.getStackingDensity());
                        vo.setStoneCompactDensity510(sysStone510.getCompactDensity());
                        vo.setStoneBulkdensity510(sysStone510.getBulkDensity());
                        Integer regionNameStone510 = sysStone510.getRegionName();
                        if (regionNameStone510 != null) {
                            Region region1 = regionMap.get(regionNameStone510);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr510(region1.getFullName());
                            }
                        }
                    }

                }

                //石头 5-25
                Integer stone525Id = smp.getStone525Id();
                if (stone525Id != null) {
                    SysStone sysStone525 = StoneMap.get(stone525Id);
                    if (sysStone525 != null) {
                        System.out.println("哈哈哈510" + sysStone525);
                        vo.setStoneModel525(sysStone525.getModel());
                        vo.setStoneSpecification525(sysStone525.getStoneSpecification());
                        vo.setStoneStackingDensity525(sysStone525.getStackingDensity());
                        vo.setStoneCompactDensity525(sysStone525.getCompactDensity());
                        vo.setStoneBulkdensity525(sysStone525.getBulkDensity());
                        Integer regionNameStone525 = sysStone525.getRegionName();
                        if (regionNameStone525 != null) {
                            Region region1 = regionMap.get(regionNameStone525);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr525(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 2040
                Integer stone2040Id = smp.getStone525Id();
                if (stone2040Id != null) {
                    SysStone sysStone2040 = StoneMap.get(stone2040Id);
                    if (sysStone2040 != null) {
                        System.out.println("哈哈哈510" + sysStone2040);
                        vo.setStoneModel2040(sysStone2040.getModel());
                        vo.setStoneSpecification2040(sysStone2040.getStoneSpecification());
                        vo.setStoneStackingDensity2040(sysStone2040.getStackingDensity());
                        vo.setStoneCompactDensity2040(sysStone2040.getCompactDensity());
                        vo.setStoneBulkdensity2040(sysStone2040.getBulkDensity());
                        Integer regionNameStone2040 = sysStone2040.getRegionName();
                        if (regionNameStone2040 != null) {
                            Region region1 = regionMap.get(regionNameStone2040);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr2040(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 10-20
                Integer stone1020Id = smp.getStone1020Id();
                if (stone1020Id != null) {
                    SysStone sysStone1020 = StoneMap.get(stone1020Id);
                    if (sysStone1020 != null) {
                        System.out.println("哈哈哈510" + sysStone1020);
                        vo.setStoneModel1020(sysStone1020.getModel());
                        vo.setStoneSpecification1020(sysStone1020.getStoneSpecification());
                        vo.setStoneStackingDensity1020(sysStone1020.getStackingDensity());
                        vo.setStoneCompactDensity1020(sysStone1020.getCompactDensity());
                        vo.setStoneBulkdensity1020(sysStone1020.getBulkDensity());
                        Integer regionNameStone1020 = sysStone1020.getRegionName();
                        if (regionNameStone1020 != null) {
                            Region region1 = regionMap.get(regionNameStone1020);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr1020(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 10-30
                Integer stone1030Id = smp.getStone1030Id();
                if (stone1030Id != null) {
                    SysStone sysStone1030 = StoneMap.get(stone1030Id);
                    if (sysStone1030 != null) {
                        System.out.println("哈哈哈510" + sysStone1030);
                        vo.setStoneModel1030(sysStone1030.getModel());
                        vo.setStoneSpecification1030(sysStone1030.getStoneSpecification());
                        vo.setStoneStackingDensity1030(sysStone1030.getStackingDensity());
                        vo.setStoneCompactDensity1030(sysStone1030.getCompactDensity());
                        vo.setStoneBulkdensity1030(sysStone1030.getBulkDensity());
                        Integer regionNameStone1030 = sysStone1030.getRegionName();
                        if (regionNameStone1030 != null) {
                            Region region1 = regionMap.get(regionNameStone1030);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr1030(region1.getFullName());
                            }
                        }
                    }
                }

                vo.setStone2031(smp.getStoneCoarse20315());
                //石头 0-10
                Integer stone010Id = smp.getStone010Id();
                if (stone010Id != null) {
                    SysStone sysStone010 = StoneMap.get(stone010Id);
                    if (sysStone010 != null) {

                        vo.setStoneModel010(sysStone010.getModel());
                        vo.setStoneSpecification010(sysStone010.getStoneSpecification());
                        vo.setStoneStackingDensity010(sysStone010.getStackingDensity());
                        vo.setStoneCompactDensity010(sysStone010.getCompactDensity());
                        vo.setStoneBulkdensity010(sysStone010.getBulkDensity());
                        Integer regionNameStone010 = sysStone010.getRegionName();
                        if (regionNameStone010 != null) {
                            Region region1 = regionMap.get(regionNameStone010);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr010(region1.getFullName());
                            }
                        }
                    }
                }

                //石头 20-315
                Integer stone20315Id = smp.getStone2031Id();
                if (stone20315Id != null) {
                    SysStone sysStone20315 = StoneMap.get(stone20315Id);
                    if (sysStone20315 != null) {

                        vo.setStoneModel20315(sysStone20315.getModel());
                        vo.setStoneSpecification20315(sysStone20315.getStoneSpecification());
                        vo.setStoneStackingDensity20315(sysStone20315.getStackingDensity());
                        vo.setStoneCompactDensity20315(sysStone20315.getCompactDensity());
                        vo.setStoneBulkdensity20315(sysStone20315.getBulkDensity());
                        Integer regionNameStone20315 = sysStone20315.getRegionName();
                        if (regionNameStone20315 != null) {
                            Region region1 = regionMap.get(regionNameStone20315);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr20315(region1.getFullName());
                            }
                        }
                    }
                }


                //砂31-37
                vo.setSand3137(smp.getSandRiverCoarse3137());
                Integer sandRiverCoarse3137Id = smp.getSandRiverCoarse3137Id();
                if (sandRiverCoarse3137Id != null) {
                    SysSand sysSand3137 = SandeMap.get(sandRiverCoarse3137Id);
                    if (sysSand3137 != null) {
                        vo.setSandType3137(sysSand3137.getType());
                        vo.setSandFineness3137(sysSand3137.getFineness());
                        vo.setSandBulkDensity3137(sysSand3137.getBulkDensity());
                        vo.setSandCompactDensity3137(sysSand3137.getCompactDensity());
                        vo.setSandApparentDensity3137(sysSand3137.getApparentDensity());
                        vo.setSandParticleSizeDistribution3137(sysSand3137.getParticleSizeDistribution());
                        Integer regionName3137 = sysSand3137.getRegionName();
                        if (regionName3137 != null) {
                            Region region1 = regionMap.get(regionName3137);
                            if (region1 != null) {
                                vo.setSandRegionNameStr3137(region1.getFullName());
                            }
                        }


                    }


                }


                //砂23-30
                vo.setSand2330(smp.getSandRiver2330Med());
                Integer sandRiverCoarse2330Id = smp.getSandRiver2330MedId();
                if (sandRiverCoarse2330Id != null) {
                    SysSand sysSand2330 = SandeMap.get(sandRiverCoarse2330Id);
                    if (sysSand2330 != null) {
                        vo.setSandType2330(sysSand2330.getType());
                        vo.setSandFineness2330(sysSand2330.getFineness());
                        vo.setSandBulkDensity2330(sysSand2330.getBulkDensity());
                        vo.setSandCompactDensity2330(sysSand2330.getCompactDensity());
                        vo.setSandApparentDensity2330(sysSand2330.getApparentDensity());
                        vo.setSandParticleSizeDistribution2330(sysSand2330.getParticleSizeDistribution());
                        Integer regionName2330 = sysSand2330.getRegionName();
                        if (regionName2330 != null) {
                            Region region1 = regionMap.get(regionName2330);
                            if (region1 != null) {
                                vo.setSandRegionNameStr2330(region1.getFullName());
                            }
                        }


                    }


                }


                //砂16-22
                vo.setSand1622(smp.getSandRiver1622Fine());
                Integer sandRiverCoarse1622Id = smp.getSandRiver1622FineId();
                if (sandRiverCoarse1622Id != null) {
                    SysSand sysSand1622 = SandeMap.get(sandRiverCoarse1622Id);
                    if (sysSand1622 != null) {
                        vo.setSandType1622(sysSand1622.getType());
                        vo.setSandFineness1622(sysSand1622.getFineness());
                        vo.setSandBulkDensity1622(sysSand1622.getBulkDensity());
                        vo.setSandCompactDensity1622(sysSand1622.getCompactDensity());
                        vo.setSandApparentDensity1622(sysSand1622.getApparentDensity());
                        vo.setSandParticleSizeDistribution1622(sysSand1622.getParticleSizeDistribution());
                        Integer regionName1622 = sysSand1622.getRegionName();
                        if (regionName1622 != null) {
                            Region region1 = regionMap.get(regionName1622);
                            if (region1 != null) {
                                vo.setSandRegionNameStr1622(region1.getFullName());
                            }
                        }

                    }

                }


                //砂2330B
                vo.setSand2330B(smp.getSandMech2330Med());
                Integer sandRiverCoarse2330BId = smp.getSandMech2330MedId();
                if (sandRiverCoarse2330BId != null) {
                    SysSand sysSand2330B = SandeMap.get(sandRiverCoarse2330BId);
                    if (sysSand2330B != null) {
                        vo.setSandType2330B(sysSand2330B.getType());
                        vo.setSandFineness2330B(sysSand2330B.getFineness());
                        vo.setSandBulkDensity2330B(sysSand2330B.getBulkDensity());
                        vo.setSandCompactDensity2330B(sysSand2330B.getCompactDensity());
                        vo.setSandApparentDensity2330B(sysSand2330B.getApparentDensity());
                        vo.setSandParticleSizeDistribution2330B(sysSand2330B.getParticleSizeDistribution());
                        Integer regionName2330B = sysSand2330B.getRegionName();
                        if (regionName2330B != null) {
                            Region region1 = regionMap.get(regionName2330B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr2330B(region1.getFullName());
                            }
                        }

                    }

                }


                //砂31-37B
                vo.setSand3137B(smp.getSandMech3137Coarse());
                Integer sandRiverCoarse3137BId = smp.getSandMech3137CoarseId();
                if (sandRiverCoarse3137BId != null) {
                    SysSand sysSand3137B = SandeMap.get(sandRiverCoarse3137BId);
                    if (sysSand3137B != null) {
                        vo.setSandType3137B(sysSand3137B.getType());
                        vo.setSandFineness3137B(sysSand3137B.getFineness());
                        vo.setSandBulkDensity3137B(sysSand3137B.getBulkDensity());
                        vo.setSandCompactDensity3137B(sysSand3137B.getCompactDensity());
                        vo.setSandApparentDensity3137B(sysSand3137B.getApparentDensity());
                        vo.setSandParticleSizeDistribution3137B(sysSand3137B.getParticleSizeDistribution());
                        Integer regionName3137B = sysSand3137B.getRegionName();
                        if (regionName3137B != null) {
                            Region region1 = regionMap.get(regionName3137B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr3137B(region1.getFullName());
                            }
                        }

                    }
                }


                //砂16-22
                vo.setSand1622B(smp.getSandMech1622Fine());
                Integer sandRiverCoarse1622BId = smp.getSandMech1622FineId();
                if (sandRiverCoarse1622BId != null) {
                    SysSand sysSand1622B = SandeMap.get(sandRiverCoarse1622BId);
                    if (sysSand1622B != null) {
                        vo.setSandType1622B(sysSand1622B.getType());
                        vo.setSandFineness1622B(sysSand1622B.getFineness());
                        vo.setSandBulkDensity1622B(sysSand1622B.getBulkDensity());
                        vo.setSandCompactDensity1622B(sysSand1622B.getCompactDensity());
                        vo.setSandApparentDensity1622B(sysSand1622B.getApparentDensity());
                        vo.setSandParticleSizeDistribution1622B(sysSand1622B.getParticleSizeDistribution());
                        Integer regionName1622B = sysSand1622B.getRegionName();
                        if (regionName1622B != null) {
                            Region region1 = regionMap.get(regionName1622B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr1622B(region1.getFullName());
                            }
                        }

                    }

                }


                //砂04-75
                vo.setSand0475(smp.getSandMech0475());
                Integer sandRiverCoarse0475Id = smp.getSandMech0475Id();
                if (sandRiverCoarse0475Id != null) {
                    SysSand sysSand0475 = SandeMap.get(sandRiverCoarse0475Id);
                    if (sysSand0475 != null) {
                        vo.setSandType0475(sysSand0475.getType());
                        vo.setSandFineness0475(sysSand0475.getFineness());
                        vo.setSandBulkDensity0475(sysSand0475.getBulkDensity());
                        vo.setSandCompactDensity0475(sysSand0475.getCompactDensity());
                        vo.setSandApparentDensity0475(sysSand0475.getApparentDensity());
                        vo.setSandParticleSizeDistribution0475(sysSand0475.getParticleSizeDistribution());
                        Integer regionName0475 = sysSand0475.getRegionName();
                        if (regionName0475 != null) {
                            Region region1 = regionMap.get(regionName0475);
                            if (region1 != null) {
                                vo.setSandRegionNameStr0475(region1.getFullName());
                            }
                        }

                    }
                }

//砂0-9
                vo.setSand09(smp.getSandMech09());
                Integer sandRiverCoarse09Id = smp.getSandMech09Id();
                if (sandRiverCoarse09Id != null) {
                    SysSand sysSand09 = SandeMap.get(sandRiverCoarse09Id);
                    if (sysSand09 != null) {
                        vo.setSandType09(sysSand09.getType());
                        vo.setSandFineness09(sysSand09.getFineness());
                        vo.setSandBulkDensity09(sysSand09.getBulkDensity());
                        vo.setSandCompactDensity09(sysSand09.getCompactDensity());
                        vo.setSandApparentDensity09(sysSand09.getApparentDensity());
                        vo.setSandParticleSizeDistribution09(sysSand09.getParticleSizeDistribution());
                        Integer regionName09 = sysSand09.getRegionName();
                        if (regionName09 != null) {
                            Region region1 = regionMap.get(regionName09);
                            if (region1 != null) {
                                vo.setSandRegionNameStr09(region1.getFullName());
                            }
                        }

                    }
                }


                //石粉
                vo.setAdmixtures(smp.getStonePowder());
                Integer stonePowderId = smp.getStonePowderId();
                if (stonePowderId != null) {
                    SysOtherAdmixtures sysOtherAdmixtures = OtherAdmixturesMap.get(stonePowderId);
                    if (sysOtherAdmixtures != null) {
                        vo.setAdmixturesModel(sysOtherAdmixtures.getModel());
                        vo.setAdmixturesFineness(sysOtherAdmixtures.getFineness());
                        vo.setAdmixturesMoistureContent(sysOtherAdmixtures.getMoistureContent());
                        vo.setAdmixturesActivityIndex28d(sysOtherAdmixtures.getActivityIndex28d());
                        Integer regionName09 = sysOtherAdmixtures.getRegionName();
                        if (regionName09 != null) {
                            Region region1 = regionMap.get(regionName09);
                            if (region1 != null) {
                                vo.setAdmixturesRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //矿粉
                vo.setMineralPowder(smp.getMineralPowder());
                Integer mineralPowderId = smp.getMineralPowderId();
                if (mineralPowderId != null) {
                    SysMineralPowder sysMineralPowder = SysMineralPowderMap.get(mineralPowderId);
                    if (sysMineralPowder != null) {
                        vo.setMineralModel(sysMineralPowder.getModel());
                        vo.setMineralSlagGrade(sysMineralPowder.getSlagGrade());
                        vo.setMineralFineness(sysMineralPowder.getFineness());
                        vo.setMineralMoistureContent(sysMineralPowder.getMoistureContent());
                        vo.setMineralActivityIndex28d(sysMineralPowder.getActivityIndex28d());

                        Integer regionName = sysMineralPowder.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setMineralRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //粉煤灰
                vo.setFlyash(smp.getFlyAsh());
                Integer flyAshId = smp.getFlyAshId();
                if (flyAshId != null) {
                    SysFlyash sysFlyash = flyashMap.get(flyAshId);
                    if (sysFlyash != null) {
                        vo.setFlyashGrade(sysFlyash.getGrade());
                        vo.setFlyashFactoryGrade(sysFlyash.getFactoryGrade());
                        vo.setFlyashFineness(sysFlyash.getFineness());
                        vo.setFlyashMoistureContent(sysFlyash.getMoistureContent());
                        vo.setFlyashActivityIndex28d(sysFlyash.getActivityIndex28d());

                        Integer regionName = sysFlyash.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setFlyashRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //减水剂

                vo.setReducer(smp.getWaterReducer());
                Integer waterReducerId = smp.getWaterReducerId();
                if (waterReducerId != null) {
                    SysWaterReducer sysWaterReducer = SysWaterReducerMap.get(waterReducerId);
                    if (sysWaterReducer != null) {
                        vo.setReducerModel(sysWaterReducer.getModel());
                        vo.setReducerSolidContent(sysWaterReducer.getSolidContent());
                        vo.setReducerCementPsteFlow(sysWaterReducer.getCementPasteFlow());
                        vo.setReducerReducingRate(sysWaterReducer.getReducingRate());
                        vo.setReducerRegionNameStr(sysWaterReducer.getSourceName());

                    }
                }


                //增效剂
                vo.setEfficiencyAgentAgent(smp.getEfficiencyAgent());
                Integer efficiencyAgentId = smp.getEfficiencyAgentId();
                if (efficiencyAgentId != null) {
                    SysEfficiencyAgent efficiencyAgent = efficiencyAgentMap.get(efficiencyAgentId);
                    if (efficiencyAgent != null) {
                        vo.setEfficiencyAgentModel(efficiencyAgent.getModel());
                        vo.setEfficiencyAgentSourceName(efficiencyAgent.getSourceName());
                    }
                }


                //膨胀剂
                vo.setSwellingAgent(smp.getExpansionAgent());
                Integer swellingAgentId = smp.getExpansionAgentId();
                if (swellingAgentId != null) {
                    SysSwellingagent sysSwellingagent = swellingagentMap.get(swellingAgentId);
                    if (sysSwellingagent != null) {
                        vo.setSwellingagentModel(sysSwellingagent.getModel());
                        vo.setSwellingagentSourceName(sysSwellingagent.getSourceName());

                    }
                }


                agentVOList.add(vo);
            }

            // 生成 Excel 文件并保存到本地
            String filePath2 = saveExcelToLocalSlumpV2(agentVOList, "坍落度");

            System.out.println(filePath2+"坍落度url");

            map.put("slump",filePath2);
            // 返回文件的 URL
            // 返回 AjaxResult，可以包含文件的 URL
        //    return AjaxResult.success("文件已生成", filePath);

        }
        System.out.println("返回数据map：" + map);

        return AjaxResult.success(map);
    }
*/






//    @PostMapping("queryCementByIdsExport")
//    public void queryCementByIdsExport(HttpServletResponse response, @RequestBody RawMaterialsDTO rawMaterialsDTO) {
//        // 从请求体中获取水泥ID列表
//        List<Integer> cementIds = rawMaterialsDTO.getCementIds();
//
//        // 创建查询条件，根据水泥ID列表查询
//        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
//        wrapper.in(SysCement::getCementId, cementIds);
//
//        // 根据ID查询水泥数据
//        List<SysCement> cementsList = sysCementService.list(wrapper);
//
//
//        List<Region> listRegion = regionService.list();
//        HashMap<Integer, Region> map = new HashMap<>();
//        for (Region region : listRegion) {
//            map.put(region.getId(), region);
//        }
//
//
//
//        // 将SysCement数据转换为CementVO
//        List<CementVO> cementsVOlist = new ArrayList<>();
//        for (SysCement cement : cementsList) {
//
//            // 获取地区名称并设置到VO中
//            Integer regionId = cement.getRegionName();
//            Region region = map.get(regionId);  // 根据regionId查找Region对象
//            if (region != null) {
//                cementsVOlist.add(cementVO);
//            }
//
//            CementVO cementVO = new CementVO();
//            // 使用BeanUtils将SysCement的属性复制到CementVO中
//            BeanUtils.copyProperties(cement, cementVO);
//            cementsVOlist.add(cementVO);
//        }
//        System.out.println("哈哈哈"+cementsList);
//        // 使用ExcelUtil工具类将数据导出为Excel文件
//        ExcelUtil<CementVO> util = new ExcelUtil<>(CementVO.class);
//        util.exportExcel(response, cementsVOlist, "水泥表");
//    }
//
//


    /**
     * 水型号模糊查询
     */
    @PostMapping("listLikeWaterModel")
    private AjaxResult listLikeWaterModel(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysWater> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysWater::getModel, name);
        }

        // 查询数据
        List<SysWater> list = waterService.list(wrapper);

        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getModel());
                    vo.setLabel(s.getModel());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 水泥型号模糊查询
     */

    @PostMapping("listLikeCementModel")
    private AjaxResult listLikeCementModel(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysCement::getModel, name);
        }

        List<SysCement> list = sysCementService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getModel());
                    vo.setLabel(s.getModel());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 水泥 安全性模糊查询
     */
    @PostMapping("listLikeCementStability")
    private AjaxResult listLikeCementStability(@RequestBody SandFinenessDTO sandFinenessDTO) {
        /*String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysCement::getStability, name);
        }

        List<SysCement> list = sysCementService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getStability());
                    vo.setLabel(s.getStability());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据*/
        return AjaxResult.success();
    }


    /**
     * 石头型号模糊查询
     */
    @PostMapping("listLikeStoneModel")
    private AjaxResult listLikeStoneModel(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysStone> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysStone::getModel, name);
        }

        List<SysStone> list = sysStoneService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getModel());
                    vo.setLabel(s.getModel());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 石头规格模糊
     */
    @PostMapping("listLikeStoneSpecification")
    private AjaxResult listLikeStoneSpecification(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysStone> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysStone::getStoneSpecification, name);
        }

        List<SysStone> list = sysStoneService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getStoneSpecification());
                    vo.setLabel(s.getStoneSpecification());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 石头颗粒级配模糊
     */


    @PostMapping("listLikeStoneParticlesizedistribution")
    private AjaxResult listLikeStoneParticlesizedistribution(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysStone> wrapper = new LambdaQueryWrapper<>();
//        // 如果 name 不为空，则添加模糊查询条件
//        if (!StringUtils.isEmpty(name)) {
//            wrapper.like(SysStone::getParticleSizeDistribution, name);
//        }

        List<SysStone> list = sysStoneService.list(wrapper);

        // 使用 HashSet 去重
        HashSet<String> uniqueParticleSizeDistributions = new HashSet<>();

        List<SandFineneVO> sandFinenessVOList = new ArrayList<>();
/*        for (SysStone stone : list) {
            String particleSizeDistribution = stone.getParticleSizeDistribution();
            // 如果集合中不存在，则添加并创建对应的 VO 对象
            if (uniqueParticleSizeDistributions.add(particleSizeDistribution)) {
                SandFineneVO vo = new SandFineneVO();
                vo.setValue(particleSizeDistribution);
                vo.setLabel(particleSizeDistribution);
                sandFinenessVOList.add(vo);
            }
        }*/

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 砂细度下拉模糊
     *
     * @return
     */

    @PostMapping("listMistedSandFineness")
    private AjaxResult listMistedSandFineness(@RequestBody SandFinenessDTO sandFinenessDTO) {
        // 调用服务层方法获取结果
        List<SysSandFineness> sysFlyashFinenessList = sysSandFinenesService.listMistedSand(sandFinenessDTO);

        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = sysFlyashFinenessList.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 砂类型下拉模糊查询1
     *
     * @return
     */
    @PostMapping("listMistedSandType")
    private AjaxResult listMistedSandType(@RequestBody SandFinenessDTO sandFinenessDTO) {

        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysSand> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysSand::getType, name);
        }

        List<SysSand> list = sysSandService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getType());
                    vo.setLabel(s.getType());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 砂规格模糊查询
     *
     * @return
     */
    @PostMapping("listMistedSandgrainsize")
    private AjaxResult listMistedSandgrainsize(@RequestBody SandFinenessDTO sandFinenessDTO) {

        String name = sandFinenessDTO.getName();

        LambdaQueryWrapper<SysSand> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
//        if (!StringUtils.isEmpty(name)) {
//            wrapper.like(SysSand::getGrainSize, name);
//        }

        List<SysSand> list = sysSandService.list(wrapper);
        // 转换成 VO 对象，并映射字段
/*
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getGrainSize());
                    vo.setLabel(s.getGrainSize());
                    return vo;
                })
                .collect(Collectors.toList());
*/

        // 返回封装好的数据
        return AjaxResult.success();


    }


    /**
     * 石颗粒级配下拉模糊
     *
     * @return
     */

    @PostMapping("listMistedStoneGrain")
    private AjaxResult listMistedStoneGrain(@RequestBody StoneGrainDTO stoneGrainDTO) {
        List<SysStoneGrain> sysStoneGrainList = sysSandFinenesService.listMistedStoneGrain(stoneGrainDTO);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = sysStoneGrainList.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 石颗粒尺寸下拉模糊查询
     *
     * @return
     */
    @PostMapping("listMistedStoneSize")
    private AjaxResult listMistedStoneSize(@RequestBody StoneGrainDTO stoneGrainDTO) {
        List<SysStoneSize> stoneSizeList = stoneSizeService.listMistedStoneSize(stoneGrainDTO);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = stoneSizeList.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 减水剂型号下拉模糊查询
     */
    @PostMapping("listWaterMistedReduce")
    private AjaxResult listWaterMistedReduce(@RequestBody StoneGrainDTO stoneGrainDTO) {
        List<SysWaterReducerType> waterReducerTypes = sysWaterReducerService.listWaterMistedReduce(stoneGrainDTO);

        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = waterReducerTypes.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);

    }


    /**
     * 粉煤灰型号的下拉模糊查询
     *
     * @return
     */
    @PostMapping("listMistedFlyashType")
    private AjaxResult listFlyashType(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();
        LambdaQueryWrapper<SysFlyash> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysFlyash::getGrade, name);
        }

        List<SysFlyash> list = sysFlyashService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getGrade());
                    vo.setLabel(s.getGrade());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 粉煤灰出厂等级模糊查询
     *
     * @param sandFinenessDTO
     * @return
     */
    @PostMapping("listMistedFlyashfactoryGrade")
    private AjaxResult listMistedFlyashfactoryGrade(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();
        LambdaQueryWrapper<SysFlyash> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysFlyash::getFactoryGrade, name);
        }

        List<SysFlyash> list = sysFlyashService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getFactoryGrade());
                    vo.setLabel(s.getFactoryGrade());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 矿粉型号模糊查询
     *
     * @param sandFinenessDTO
     * @return
     */
    @PostMapping("listMistedMineralModel")
    private AjaxResult listMistedMineralModel(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();
        LambdaQueryWrapper<SysMineralPowder> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysMineralPowder::getModel, name);
        }

        List<SysMineralPowder> list = sysMineralPowderService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getModel());
                    vo.setLabel(s.getModel());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 矿粉等级模糊查询
     * slag_grade
     *
     * @return
     */
    @PostMapping("listMistedMineralSlagGrade")
    private AjaxResult listMistedMineralSlagGrade(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();
        LambdaQueryWrapper<SysMineralPowder> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysMineralPowder::getSlagGrade, name);
        }

        List<SysMineralPowder> list = sysMineralPowderService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = list.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getSlagGrade());
                    vo.setLabel(s.getSlagGrade());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    /**
     * 其他掺合料型号模糊
     *
     * @return
     */
    @PostMapping("listMistedOtherAdmixturesModel")
    private AjaxResult listMistedOtherAdmixturesModel(@RequestBody SandFinenessDTO sandFinenessDTO) {
        String name = sandFinenessDTO.getName();
        LambdaQueryWrapper<SysOtherAdmixtures> wrapper = new LambdaQueryWrapper<>();
        // 如果 name 不为空，则添加模糊查询条件
        if (!StringUtils.isEmpty(name)) {
            wrapper.like(SysOtherAdmixtures::getModel, name);
        }

        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list(wrapper);
        // 转换成 VO 对象，并映射字段
        List<SandFineneVO> sandFinenessVOList = listOtherAdmixtures.stream()
                .map(s -> {
                    SandFineneVO vo = new SandFineneVO();
                    vo.setValue(s.getModel());
                    vo.setLabel(s.getModel());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);


    }


    @GetMapping("listSandFineness")
    public AjaxResult listSandFineness() {
        // 获取原始数据
        List<SysSandFineness> listSandFinenesses = sysSandFinenesService.listSandFineness();

        // 转换成VO对象，并映射字段
        List<SandFinenessVO> sandFinenessVOList = listSandFinenesses.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        // 返回封装好的数据
        return AjaxResult.success(sandFinenessVOList);
    }


    /**
     * 查询砂类型
     *
     * @return
     */

    @GetMapping("listSandType")
    private AjaxResult listSandType() {
        List<SysSandType> sandTypeList = sysSandTypeService.listSandType();
        // 转换成VO对象，并映射字段
        List<SandFinenessVO> sandFinenessVOList = sandTypeList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        return AjaxResult.success(sandFinenessVOList);
    }

    /**
     * 石颗粒级配
     */
    @GetMapping("listStoneGrain")
    public AjaxResult listStoneGrain() {
        List<SysStoneGrain> sysStoneGrainList = sysStoneGrainService.listStoneGrain();

        List<SandFinenessVO> sysStoneGrainVOList = sysStoneGrainList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());


        return AjaxResult.success(sysStoneGrainVOList);
    }


    /**
     * 查询石头颗粒尺寸
     */
    @GetMapping("listStoneSize")
    public AjaxResult listStoneSize() {
        List<SysStoneSize> stoneSizeList = stoneSizeService.listStoneSize();


        List<SandFinenessVO> sysStoneSizeVOList = stoneSizeList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());
        return AjaxResult.success(sysStoneSizeVOList);
    }


    /**
     * 查询粉煤灰类型
     *
     * @return
     */
    @GetMapping("listflyashType")
    public AjaxResult listflyashType() {
        List<SysFlyashType> sysFlyashTypeList = sysFlyashTypeService.listflyashType();
        List<SandFinenessVO> sysFlyashTypeVOList = sysFlyashTypeList.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        return AjaxResult.success(sysFlyashTypeVOList);
    }

    /**
     * 查询粉煤灰细度
     */
    @GetMapping("listFlyashFinenes")
    public AjaxResult listFlyashFinenes() {
        List<SysFlyashFineness> sysFlyashFinenesses = sysFlyashFinenessService.listFlyashFinenes();

        List<SandFinenessVO> sysFlyashFinenessesVOList = sysFlyashFinenesses.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());
        return AjaxResult.success(sysFlyashFinenessesVOList);
    }


    /**
     * 查询减水剂类型
     *
     * @return
     */

    @GetMapping("listWaterReducerType")
    public AjaxResult listWaterReducerType() {
        List<SysWaterReducerType> listWaterReducerType = sysWaterReducerTypeService.listWaterReducerType();
        List<SandFinenessVO> sysFlyashFinenessesVOList = listWaterReducerType.stream()
                .map(s -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(s.getName());
                    vo.setLabel(s.getName());
                    return vo;
                })
                .collect(Collectors.toList());

        return AjaxResult.success(sysFlyashFinenessesVOList);
    }


    /**
     * 查询耐久性能最大值最小值
     */

//    @GetMapping("/queryDurabilityPerformanceaxMin")
//    public AjaxResult queryDurabilityPerformanceaxMin() {
//        // 调用服务层获取数据
//        Map<String, Object> durabilityPerformanceMinAndMax = sysDurabilityPerformanceService.queryDurabilityPerformanceaxMin();
//
//        return AjaxResult.success(durabilityPerformanceMinAndMax);
//    }

    /**
     * 查询耐久性能表的最大值和最小值
     *
     * @return
     */
    @GetMapping("/queryDurabilityPerformancePullDown")
    public AjaxResult queryDurabilityPerformanceMinAndMax() {
        // 调用服务层获取数据
        Map<String, Object> durabilityMinAndMax = sysDurabilityPerformanceService.queryDurabilityPerformanceaxMin();

        // 构造符合需求的返回格式
        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", durabilityMinAndMax.get("minWaterContent"));
        waterContent.put("max", durabilityMinAndMax.get("maxWaterContent"));

        Map<String, Object> freezeResistanceLevel = new HashMap<>();
        freezeResistanceLevel.put("min", durabilityMinAndMax.get("minFreezeResistanceLevel"));
        freezeResistanceLevel.put("max", durabilityMinAndMax.get("maxFreezeResistanceLevel"));

        Map<String, Object> impermeabilityLevel = new HashMap<>();
        impermeabilityLevel.put("min", durabilityMinAndMax.get("minImpermeabilityLevel"));
        impermeabilityLevel.put("max", durabilityMinAndMax.get("maxImpermeabilityLevel"));

        Map<String, Object> carbonationDepth = new HashMap<>();
        carbonationDepth.put("min", durabilityMinAndMax.get("minCarbonationDepth"));
        carbonationDepth.put("max", durabilityMinAndMax.get("maxCarbonationDepth"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", durabilityMinAndMax.get("minCementContent"));
        cementContent.put("max", durabilityMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", durabilityMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", durabilityMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", durabilityMinAndMax.get("minSandContent"));
        sandContent.put("max", durabilityMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", durabilityMinAndMax.get("minStoneContent"));
        stoneContent.put("max", durabilityMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", durabilityMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", durabilityMinAndMax.get("maxWaterReducerDosage"));

        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", durabilityMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", durabilityMinAndMax.get("maxEfficiencyAgentDosage"));

        Map<String, Object> waterDosage = new HashMap<>();
        waterDosage.put("min", durabilityMinAndMax.get("minWaterDosage"));
        waterDosage.put("max", durabilityMinAndMax.get("maxWaterDosage"));

        Map<String, Object> powderDosage = new HashMap<>();
        powderDosage.put("min", durabilityMinAndMax.get("minPowderDosage"));
        powderDosage.put("max", durabilityMinAndMax.get("maxPowderDosage"));


        Map<String, Object> admixturesDosage = new HashMap<>();
        admixturesDosage.put("min", durabilityMinAndMax.get("minAdmixturesDosage"));
        admixturesDosage.put("max", durabilityMinAndMax.get("maxAdmixturesDosage"));


        Map<String, Object> swellingagentDosage = new HashMap<>();
        swellingagentDosage.put("min", durabilityMinAndMax.get("minSwellingagentDosage"));
        swellingagentDosage.put("max", durabilityMinAndMax.get("maxSwellingagentDosage"));


        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("waterContent", waterContent); // 水用量，单位为 kg/m³
        sliderSection.put("freezeResistanceLevel", freezeResistanceLevel); // 抗冻等级，表示材料耐受冻融循环的性能
        sliderSection.put("impermeabilityLevel", impermeabilityLevel); // 抗渗等级，表示材料抵抗水渗透能力的性能等级
        sliderSection.put("carbonationDepth", carbonationDepth); // 碳化深度，单位为 mm，用于衡量材料碳化程度
        sliderSection.put("cementContent", cementContent); // 水泥用量，单位为 kg/m³
        sliderSection.put("flyAshContent", flyAshContent); // 粉煤灰用量，单位为 kg/m³
        sliderSection.put("sandContent", sandContent); // 砂用量，单位为 kg/m³
        sliderSection.put("stoneContent", stoneContent); // 石料用量，单位为 kg/m³
        sliderSection.put("waterReducerDosage", waterReducerDosage); // 减水剂掺量，单位为百分比 (%)
        sliderSection.put("synergyDosage", efficiencyAgentDosage); // 增效剂掺量，单位为百分比 (%)


        sliderSection.put("waterDosage", waterDosage);//水掺量（%）
        sliderSection.put("powderDosage", powderDosage);///矿粉掺量
        sliderSection.put("admixturesDosage", admixturesDosage);//其他参合料掺量
        sliderSection.put("swellingagentDosage", swellingagentDosage);//膨胀剂掺量


        HashMap<Object, Object> idList = new HashMap<>();
// 获取ID列表并转换为所需格式
        Function<List<Integer>, List<Map<String, String>>> convertToValueLabelList = list ->
                list.stream()
                        .map(id -> {
                            Map<String, String> item = new HashMap<>();
                            item.put("value", String.valueOf(id));
                            item.put("label", String.valueOf(id));
                            return item;
                        })
                        .collect(Collectors.toList());


        List<Map<String, String>> regionIdList = convertToValueLabelList.apply(
                isysRegionService.listRegions().stream().map(SysRegion::getRegionId).collect(Collectors.toList())
        );

        List<Map<String, String>> cementIdList = convertToValueLabelList.apply(
                sysCementService.listCement().stream().map(SysCement::getCementId).collect(Collectors.toList())
        );

        List<Map<String, String>> sandIdList = convertToValueLabelList.apply(
                sysSandService.listSand().stream().map(SysSand::getSandId).collect(Collectors.toList())
        );

        List<Map<String, String>> stoneIdList = convertToValueLabelList.apply(
                sysStoneService.listStones().stream().map(SysStone::getStoneId).collect(Collectors.toList())
        );

        List<Map<String, String>> waterReducerList = convertToValueLabelList.apply(
                sysWaterReducerService.listWaterReduce().stream()
                        .map(reducer -> reducer.getReducerId().intValue())
                        .collect(Collectors.toList())
        );

        List<Map<String, String>> flyashIdList = convertToValueLabelList.apply(
                sysFlyashService.listFlyash().stream().map(SysFlyash::getFlyashId).collect(Collectors.toList())
        );


        List<Map<String, String>> efficiencyAgentIdList = convertToValueLabelList.apply(
                sysEfficiencyAgent.listefficiencyAgents().stream()
                        .map(agent -> agent.getAgentId().intValue())
                        .collect(Collectors.toList())
        );
        List<SysRegion> regionList = isysRegionService.listRegions();
        idList.put("regionIdList", regionIdList);
        idList.put("cementIdList", cementIdList);
        idList.put("sandIdList", sandIdList);
        idList.put("stoneIdList", stoneIdList);
        idList.put("waterReducerList", waterReducerList);
        idList.put("regionList", regionList);
        idList.put("flyashIdList", flyashIdList);
        idList.put("efficiencyAgentIdList", efficiencyAgentIdList);//增效剂掺量


/*        // 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        for (SysCement sysCement : sysCementList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysCement.getModel());
            labelValueMap.put("value", sysCement.getCementId());
            cementIdListPlus.add(labelValueMap);
        }

        // 地区
        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionName());
            labelValueMap.put("value", sysRegion.getRegionId());

            listRegionList.add(labelValueMap);
        }


        List<SysSand> listSysSands = sysSandService.listSand();

        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        for (SysSand sysRegion : listSysSands) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getType());
            labelValueMap.put("value", sysRegion.getSandId());

            listSysSandLists.add(labelValueMap);
        }

        //石头
        List<SysStone> sysStoneList = sysStoneService.listStones();

        List<Map<String, Object>> listStoneList = new ArrayList<>();
        for (SysStone sysStone : sysStoneList) {
            Map<String, Object> labelStoneValueMaps = new HashMap<>();
            labelStoneValueMaps.put("label", sysStone.getParticleSizeDistribution());
            labelStoneValueMaps.put("value", sysStone.getStoneId());
            listStoneList.add(labelStoneValueMaps);
        }

        //减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        for (SysWaterReducer reducer : reducers) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", reducer.getModel());
            labelValueMap.put("value", reducer.getReducerId());
            listWaterList.add(labelValueMap);
        }

        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysFlyash.getGrade());
            labelValueMap.put("value", sysFlyash.getFlyashId());
            listFlyashList.add(labelValueMap);

        }


        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();

        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", efficiencyAgent.getModel());
            labelValueMap.put("value", efficiencyAgent.getId());
            efficiencyAgentList.add(labelValueMap);
        }


        // 水型号
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        List<SysWater> listWaterModelList = waterService.list();
        for (SysWater sysWater : listWaterModelList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }
        //矿粉型号
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        for (SysMineralPowder sysWater : listMineralPowderList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            mineralPowderList.add(labelValueMap);

        }

        //其他型号
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        for (SysOtherAdmixtures sysWater : listOtherAdmixturesList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }

        //膨胀剂型号
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        for (SysSwellingagent sysWater : listSwellingagentList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            swellingagentList.add(labelValueMap);

        }*/


// 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        Set<String> cementSet = new HashSet<>();
        for (SysCement sysCement : sysCementList) {
            String model = sysCement.getModel();
            if (cementSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", sysCement.getCementId());
                cementIdListPlus.add(labelValueMap);
            }
        }

// 地区 - 保留原逻辑
        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionId());
            labelValueMap.put("value", sysRegion.getRegionName());
            listRegionList.add(labelValueMap);
        }


// 砂类型
        List<SysSand> listSysSands = sysSandService.listSand();
        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        Set<String> sandSet = new HashSet<>();
        for (SysSand sysSand : listSysSands) {
            String type = sysSand.getType();
            if (sandSet.add(type)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", type);
                labelValueMap.put("value", sysSand.getSandId());
                listSysSandLists.add(labelValueMap);
            }
        }

        // 石头
        List<SysStone> sysStoneList = sysStoneService.listStones();
        List<Map<String, Object>> listStoneList = new ArrayList<>();
        Set<String> stoneSet = new HashSet<>();
/*        for (SysStone sysStone : sysStoneList) {
            String distribution = sysStone.getParticleSizeDistribution();
            if (stoneSet.add(distribution)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", distribution);
                labelValueMap.put("value", sysStone.getStoneId());
                listStoneList.add(labelValueMap);
            }
        }*/

        // 减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        Set<String> reducerSet = new HashSet<>();
        for (SysWaterReducer reducer : reducers) {
            String model = reducer.getModel();
            if (reducerSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", reducer.getReducerId());
                listWaterList.add(labelValueMap);
            }
        }

        // 粉煤灰
        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        Set<String> flyashSet = new HashSet<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            String grade = sysFlyash.getGrade();
            if (flyashSet.add(grade)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", grade);
                labelValueMap.put("value", sysFlyash.getFlyashId());
                listFlyashList.add(labelValueMap);
            }
        }

        // 高效剂
        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();
        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        Set<String> efficiencySet = new HashSet<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            String model = efficiencyAgent.getModel();
            if (efficiencySet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", efficiencyAgent.getId());
                efficiencyAgentList.add(labelValueMap);
            }
        }

        // 水型号
        List<SysWater> listWaterModelList = waterService.list();
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        Set<String> waterSet = new HashSet<>();
        for (SysWater sysWater : listWaterModelList) {
            String model = sysWater.getModel();
            if (waterSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                waterModelList.add(labelValueMap);
            }
        }

// 矿粉型号
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        Set<String> mineralPowderSet = new HashSet<>();
        for (SysMineralPowder sysMineralPowder : listMineralPowderList) {
            String model = sysMineralPowder.getModel();
            if (mineralPowderSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                mineralPowderList.add(labelValueMap);
            }
        }

// 其他型号
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        Set<String> admixturesSet = new HashSet<>();
        for (SysOtherAdmixtures sysOtherAdmixtures : listOtherAdmixturesList) {
            String model = sysOtherAdmixtures.getModel();
            if (admixturesSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                otherAdmixturesList.add(labelValueMap);
            }
        }

// 膨胀剂型号
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        Set<String> swellingagentSet = new HashSet<>();
        for (SysSwellingagent sysSwellingagent : listSwellingagentList) {
            String model = sysSwellingagent.getModel();
            if (swellingagentSet.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                swellingagentList.add(labelValueMap);
            }
        }


        // 创建 idsPlus 并填充数据
        Map<String, Object> idListPlus = new HashMap<>();
        idListPlus.put("regionIdList", listRegionList);
        idListPlus.put("cementIdList", cementIdListPlus);
        idListPlus.put("sandIdList", listSysSandLists);
        idListPlus.put("stoneIdList", listStoneList);
        idListPlus.put("waterReducerList", listWaterList);
        idListPlus.put("flyashIdList", listFlyashList);
        idListPlus.put("efficiencyAgentIdList", efficiencyAgentList);
        idListPlus.put("regionList", "");


        idListPlus.put("waterModel", waterModelList);//水
        idListPlus.put("mineralModel", mineralPowderList);//矿粉
        idListPlus.put("otherAdmixturesModel", otherAdmixturesList);//其他型号
        idListPlus.put("swellingagentModel", swellingagentList);//    //其他型号


        Map<String, Object> result = new HashMap<>();
        result.put("sliderSection", sliderSection);
        //result.put("ids", idList);
        result.put("ids", idListPlus);
        // 返回 AjaxResult
        return AjaxResult.success(result);
    }


    /**
     * 查询水泥表的最大值和最小值
     *
     * @return
     */
    @GetMapping("/queryCementMinAndMax")
    public AjaxResult queryCementMinAndMax() {
        // 调用服务层获取数据
        Map<String, Object> cementMinAndMax = sysCementService.getCementMinAndMax();
        // 构造符合需求的返回格式
        Map<String, Object> cementCaO = new HashMap<>();
        cementCaO.put("min", cementMinAndMax.get("minCaocontent"));
        cementCaO.put("max", cementMinAndMax.get("maxCaocontent"));
        Map<String, Object> cementSiO2 = new HashMap<>();
        cementSiO2.put("min", cementMinAndMax.get("minSio2content"));
        cementSiO2.put("max", cementMinAndMax.get("maxSio2content"));
        Map<String, Object> cementAl2O3 = new HashMap<>();
        cementAl2O3.put("min", cementMinAndMax.get("minAl2o3content"));
        cementAl2O3.put("max", cementMinAndMax.get("maxAl2o3content"));
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("cementCaO", cementCaO);
        sliderSection.put("cementSiO2", cementSiO2);
        sliderSection.put("cementAl2O3", cementAl2O3);
        Map<String, Object> result = new HashMap<>();
        result.put("sliderSection", sliderSection);
        // 返回 AjaxResult
        return AjaxResult.success(result);
    }


    /**
     * 查询石头表的最大值最小值
     */
    @GetMapping("/queryStoneMinAndMax")
    public ResponseEntity<Map<String, Object>> queryStoneMinAndMax() {
        // 从服务层获取数据
        Map<String, Object> stoneMinAndMax = sysStoneService.getStoneMinAndMax();

        // 封装 cementCaO 数据
        Map<String, Object> stoneDensity = new HashMap<>();
        stoneDensity.put("min", stoneMinAndMax.get("minBulkdensity"));
        stoneDensity.put("max", stoneMinAndMax.get("maxBulkdensity"));
        // 返回整体结果
        Map<String, Object> result = new HashMap<>();
        result.put("stoneDensity", stoneDensity);

        return ResponseEntity.ok(result);
    }


    /**
     * 查询减水剂的最大值最小值
     */
    @GetMapping("querywaterReducerMinAndMax")
    public AjaxResult querywaterReducerMinAndMax() {
        // 调用 service 获取最大值最小值
        Map<String, Object> waterReducerMinAndMax = sysWaterReducerService.getwaterReducerAndMax();

        // 构建符合要求的返回格式
        Map<String, Object> solidContent = new HashMap<>();
        solidContent.put("min", waterReducerMinAndMax.get("minSolidContent"));
        solidContent.put("max", waterReducerMinAndMax.get("maxSolidContent"));

        Map<String, Object> reducingRate = new HashMap<>();
        reducingRate.put("min", waterReducerMinAndMax.get("minReducingRate"));
        reducingRate.put("max", waterReducerMinAndMax.get("maxReducingRate"));

        // 封装 sliderSection 对象
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("solidContent", solidContent);
        sliderSection.put("reducingRate", reducingRate);

        // 返回结果
        return AjaxResult.success(sliderSection);
    }

    /**
     * 查询粉煤灰表的最大值最小值
     */

    @GetMapping("/queryFlyashMaxMin")
    public AjaxResult queryFlyashMaxMin() {
        // 调用 service 获取最大值和最小值
        Map<String, Object> flyashMinAndMax = sysFlyashService.queryFlyashMaxMin();
        // 构建符合要求的返回格式
        Map<String, Object> fineness = new HashMap<>();
        fineness.put("min", flyashMinAndMax.get("minFineness"));
        fineness.put("max", flyashMinAndMax.get("maxFineness"));
        // 封装到最终返回的 Map
        Map<String, Object> result = new HashMap<>();
        result.put("fineness", fineness);
        // 返回结果
        return AjaxResult.success(result);
    }


    /**
     * 查询力学性能的最大值最小值
     */
    @GetMapping("queryMechanicalPerformanceMaxMin")
    public AjaxResult queryMechanicalPerformanceMaxMin() {
        // 获取从数据库中查询到的最大值和最小值
        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> compressiveStrength7d = new HashMap<>();
        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));

        Map<String, Object> compressiveStrength28d = new HashMap<>();
        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", efficiencyMerchantMinAndMax.get("minWaterContent"));
        waterContent.put("max", efficiencyMerchantMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", efficiencyMerchantMinAndMax.get("minCementContent"));
        cementContent.put("max", efficiencyMerchantMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", efficiencyMerchantMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", efficiencyMerchantMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", efficiencyMerchantMinAndMax.get("minSandContent"));
        sandContent.put("max", efficiencyMerchantMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", efficiencyMerchantMinAndMax.get("minStoneContent"));
        stoneContent.put("max", efficiencyMerchantMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducerDosage"));

        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", efficiencyMerchantMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", efficiencyMerchantMinAndMax.get("maxEfficiencyAgentDosage"));


        // 将所有的结果封装到最终的返回 Map 中
        Map<String, Object> result = new HashMap<>();
        result.put("compressiveStrength7d", compressiveStrength7d);
        result.put("compressiveStrength28d", compressiveStrength28d);

        result.put("waterContent", waterContent);
        result.put("cementContent", cementContent);
        result.put("flyAshContent", flyAshContent);
        result.put("sandContent", sandContent);
        result.put("stoneContent", stoneContent);
        result.put("waterReducerDosage", waterReducerDosage);
        result.put("synergyDosage", efficiencyAgentDosage);

        // 返回结果
        return AjaxResult.success(result);
    }


    /**
     * 查询变形性能的最大值最小值
     */
    @GetMapping("querylistDeformationMaxMin")
    public AjaxResult querylistDeformationMaxMin() {
        // 获取从数据库中查询到的最大值和最小值
        Map<String, Object> deformationPerformanceMinAndMax = sysDeformationPerformanceService.queryDeformationPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> shrinkage7d = new HashMap<>();
        shrinkage7d.put("min", deformationPerformanceMinAndMax.get("minShrinkage7d"));
        shrinkage7d.put("max", deformationPerformanceMinAndMax.get("maxShrinkage7d"));

        Map<String, Object> shrinkage28d = new HashMap<>();
        shrinkage28d.put("min", deformationPerformanceMinAndMax.get("minShrinkage28d"));
        shrinkage28d.put("max", deformationPerformanceMinAndMax.get("maxShrinkage28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", deformationPerformanceMinAndMax.get("minWaterContent"));
        waterContent.put("max", deformationPerformanceMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", deformationPerformanceMinAndMax.get("minCementContent"));
        cementContent.put("max", deformationPerformanceMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", deformationPerformanceMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", deformationPerformanceMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", deformationPerformanceMinAndMax.get("minSandContent"));
        sandContent.put("max", deformationPerformanceMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", deformationPerformanceMinAndMax.get("minStoneContent"));
        stoneContent.put("max", deformationPerformanceMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", deformationPerformanceMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", deformationPerformanceMinAndMax.get("maxWaterReducerDosage"));

        // 将所有的结果封装到最终的返回 Map 中
        Map<String, Object> result = new HashMap<>();
        result.put("shrinkage7d", shrinkage7d);
        result.put("shrinkage28d", shrinkage28d);
        result.put("waterContent", waterContent);
        result.put("cementContent", cementContent);
        result.put("flyAshContent", flyAshContent);
        result.put("sandContent", sandContent);
        result.put("stoneContent", stoneContent);
        result.put("waterReducerDosage", waterReducerDosage);

        // 返回结果
        return AjaxResult.success(result);
    }


    /**
     * 查询耐久性能最大值最小值
     */
//    @GetMapping("querylistDurabilityPerformanceMaxMin")
//    public AjaxResult querylistDurabilityPerformanceMaxMin() {
//
//        sysEfficiencyMerchantNameService.querylistDurabilityPerformanceMaxMin();
//
//    }


    /**
     * 查询变形性能下拉框信息
     */
    @GetMapping("listDeformationPullDown")
    public AjaxResult listDeformationPullDown() {

        Map<String, Object> deformationPerformanceMinAndMax = sysDeformationPerformanceService.queryDeformationPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> shrinkage7d = new HashMap<>();
        shrinkage7d.put("min", deformationPerformanceMinAndMax.get("minShrinkage7d"));
        shrinkage7d.put("max", deformationPerformanceMinAndMax.get("maxShrinkage7d"));

        Map<String, Object> shrinkage28d = new HashMap<>();
        shrinkage28d.put("min", deformationPerformanceMinAndMax.get("minShrinkage28d"));
        shrinkage28d.put("max", deformationPerformanceMinAndMax.get("maxShrinkage28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", deformationPerformanceMinAndMax.get("minWaterContent"));
        waterContent.put("max", deformationPerformanceMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", deformationPerformanceMinAndMax.get("minCementContent"));
        cementContent.put("max", deformationPerformanceMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", deformationPerformanceMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", deformationPerformanceMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", deformationPerformanceMinAndMax.get("minSandContent"));
        sandContent.put("max", deformationPerformanceMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", deformationPerformanceMinAndMax.get("minStoneContent"));
        stoneContent.put("max", deformationPerformanceMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", deformationPerformanceMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", deformationPerformanceMinAndMax.get("maxWaterReducerDosage"));

        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", deformationPerformanceMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", deformationPerformanceMinAndMax.get("maxEfficiencyAgentDosage"));


        Map<String, Object> waterDosage = new HashMap<>();
        waterDosage.put("min", deformationPerformanceMinAndMax.get("minWaterDosage"));
        waterDosage.put("max", deformationPerformanceMinAndMax.get("maxWaterDosage"));

        Map<String, Object> powderDosage = new HashMap<>();
        powderDosage.put("min", deformationPerformanceMinAndMax.get("minPowderDosage"));
        powderDosage.put("max", deformationPerformanceMinAndMax.get("maxPowderDosage"));


        Map<String, Object> admixturesDosage = new HashMap<>();
        admixturesDosage.put("min", deformationPerformanceMinAndMax.get("minAdmixturesDosage"));
        admixturesDosage.put("max", deformationPerformanceMinAndMax.get("maxAdmixturesDosage"));


        Map<String, Object> swellingagentDosage = new HashMap<>();
        swellingagentDosage.put("min", deformationPerformanceMinAndMax.get("minSwellingagentDosage"));
        swellingagentDosage.put("max", deformationPerformanceMinAndMax.get("maxSwellingagentDosage"));


        // 将所有的结果封装到最终的返回 Map 中
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("shrinkage7d", shrinkage7d);
        sliderSection.put("shrinkage28d", shrinkage28d);
        sliderSection.put("waterContent", waterContent);
        sliderSection.put("cementContent", cementContent);
        sliderSection.put("flyAshContent", flyAshContent);
        sliderSection.put("sandContent", sandContent);
        sliderSection.put("stoneContent", stoneContent);
        sliderSection.put("waterReducerDosage", waterReducerDosage);
        sliderSection.put("synergyDosage", efficiencyAgentDosage);

        sliderSection.put("waterDosage", waterDosage);//水掺量（%）
        sliderSection.put("powderDosage", powderDosage);///矿粉掺量
        sliderSection.put("admixturesDosage", admixturesDosage);//其他参合料掺量
        sliderSection.put("swellingagentDosage", swellingagentDosage);//膨胀剂掺量


        // 获取ID列表并转换为所需格式
        Function<List<Integer>, List<Map<String, String>>> convertToValueLabelList = list ->
                list.stream()
                        .map(id -> {
                            Map<String, String> item = new HashMap<>();
                            item.put("value", String.valueOf(id));
                            item.put("label", String.valueOf(id));
                            return item;
                        })
                        .collect(Collectors.toList());


        List<Map<String, String>> regionIdList = convertToValueLabelList.apply(
                isysRegionService.listRegions().stream().map(SysRegion::getRegionId).collect(Collectors.toList())
        );

        List<Map<String, String>> cementIdList = convertToValueLabelList.apply(
                sysCementService.listCement().stream().map(SysCement::getCementId).collect(Collectors.toList())
        );

        List<Map<String, String>> sandIdList = convertToValueLabelList.apply(
                sysSandService.listSand().stream().map(SysSand::getSandId).collect(Collectors.toList())
        );

        List<Map<String, String>> stoneIdList = convertToValueLabelList.apply(
                sysStoneService.listStones().stream().map(SysStone::getStoneId).collect(Collectors.toList())
        );

        List<Map<String, String>> waterReducerList = convertToValueLabelList.apply(
                sysWaterReducerService.listWaterReduce().stream()
                        .map(reducer -> reducer.getReducerId().intValue())
                        .collect(Collectors.toList())
        );

        List<Map<String, String>> flyashIdList = convertToValueLabelList.apply(
                sysFlyashService.listFlyash().stream().map(SysFlyash::getFlyashId).collect(Collectors.toList())
        );


        List<Map<String, String>> efficiencyAgentIdList = convertToValueLabelList.apply(
                sysEfficiencyAgent.listefficiencyAgents().stream()
                        .map(agent -> agent.getAgentId().intValue())
                        .collect(Collectors.toList())
        );


        List<SysRegion> regionList = isysRegionService.listRegions();
        Map<String, Object> idList = new HashMap<>();
        idList.put("regionList", regionList);

        idList.put("regionIdList", regionIdList);
        idList.put("cementIdList", cementIdList);
        idList.put("sandIdList", sandIdList);
        idList.put("stoneIdList", stoneIdList);
        idList.put("waterReducerList", waterReducerList);
        idList.put("regionList", regionList);
        idList.put("flyashIdList", flyashIdList);
        idList.put("efficiencyAgentIdList", efficiencyAgentIdList);//增效剂掺量

/*
        // 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        for (SysCement sysCement : sysCementList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysCement.getModel());
            labelValueMap.put("value", sysCement.getModel());
            cementIdListPlus.add(labelValueMap);
        }

        // 地区
        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionName());
            labelValueMap.put("value", sysRegion.getRegionName());

            listRegionList.add(labelValueMap);
        }


        List<SysSand> listSysSands = sysSandService.listSand();

        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        for (SysSand sysRegion : listSysSands) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getType());
            labelValueMap.put("value",  sysRegion.getType());

            listSysSandLists.add(labelValueMap);
        }

        //石头
        List<SysStone> sysStoneList = sysStoneService.listStones();

        List<Map<String, Object>> listStoneList = new ArrayList<>();
        for (SysStone sysStone : sysStoneList) {
            Map<String, Object> labelStoneValueMaps = new HashMap<>();
            labelStoneValueMaps.put("label", sysStone.getParticleSizeDistribution());
            labelStoneValueMaps.put("value", sysStone.getParticleSizeDistribution());
            listStoneList.add(labelStoneValueMaps);
        }

        //减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        for (SysWaterReducer reducer : reducers) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", reducer.getModel());
            labelValueMap.put("value", reducer.getModel());
            listWaterList.add(labelValueMap);
        }

        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysFlyash.getGrade());
            labelValueMap.put("value", sysFlyash.getGrade());
            listFlyashList.add(labelValueMap);

        }


        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();

        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", efficiencyAgent.getModel());
            labelValueMap.put("value", efficiencyAgent.getModel());
            efficiencyAgentList.add(labelValueMap);
        }





        // 水型号
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        List<SysWater> listWaterModelList = waterService.list();
        for (SysWater sysWater : listWaterModelList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }




        //矿粉型号
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        for (SysMineralPowder sysWater : listMineralPowderList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            mineralPowderList.add(labelValueMap);

        }

        //其他型号
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        for (SysOtherAdmixtures sysWater : listOtherAdmixturesList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }

        //膨胀剂型号
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        for (SysSwellingagent sysWater : listSwellingagentList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            swellingagentList.add(labelValueMap);

        }*/


// 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        Set<String> cementModels = new HashSet<>();
        for (SysCement sysCement : sysCementList) {
            String model = sysCement.getModel();
            if (cementModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                cementIdListPlus.add(labelValueMap);
            }
        }

// 地区

        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionId());
            labelValueMap.put("value", sysRegion.getRegionName());
            listRegionList.add(labelValueMap);
        }

// 砂类型
        List<SysSand> listSysSands = sysSandService.listSand();
        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        Set<String> sandTypes = new HashSet<>();
        for (SysSand sysSand : listSysSands) {
            String type = sysSand.getType();
            if (sandTypes.add(type)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", type);
                labelValueMap.put("value", type);
                listSysSandLists.add(labelValueMap);
            }
        }

// 石头类型
        List<SysStone> sysStoneList = sysStoneService.listStones();
        List<Map<String, Object>> listStoneList = new ArrayList<>();
        Set<String> stoneDistributions = new HashSet<>();
/*        for (SysStone sysStone : sysStoneList) {
            String distribution = sysStone.getParticleSizeDistribution();
            if (stoneDistributions.add(distribution)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", distribution);
                labelValueMap.put("value", distribution);
                listStoneList.add(labelValueMap);
            }
        }*/

// 减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        Set<String> waterReducerModels = new HashSet<>();
        for (SysWaterReducer reducer : reducers) {
            String model = reducer.getModel();
            if (waterReducerModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                listWaterList.add(labelValueMap);
            }
        }

// 粉煤灰
        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        Set<String> flyashGrades = new HashSet<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            String grade = sysFlyash.getGrade();
            if (flyashGrades.add(grade)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", grade);
                labelValueMap.put("value", grade);
                listFlyashList.add(labelValueMap);
            }
        }

// 高效剂
        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();
        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        Set<String> efficiencyAgentModels = new HashSet<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            String model = efficiencyAgent.getModel();
            if (efficiencyAgentModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                efficiencyAgentList.add(labelValueMap);
            }
        }

// 水型号
        List<SysWater> listWaterModelList = waterService.list();
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        Set<String> waterModels = new HashSet<>();
        for (SysWater sysWater : listWaterModelList) {
            String model = sysWater.getModel();
            if (waterModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                waterModelList.add(labelValueMap);
            }
        }

// 矿粉型号
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        Set<String> mineralPowderModels = new HashSet<>();
        for (SysMineralPowder sysMineralPowder : listMineralPowderList) {
            String model = sysMineralPowder.getModel();
            if (mineralPowderModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                mineralPowderList.add(labelValueMap);
            }
        }

// 其他型号
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        Set<String> otherAdmixtureModels = new HashSet<>();
        for (SysOtherAdmixtures sysOtherAdmixtures : listOtherAdmixturesList) {
            String model = sysOtherAdmixtures.getModel();
            if (otherAdmixtureModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                otherAdmixturesList.add(labelValueMap);
            }
        }

// 膨胀剂型号
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        Set<String> swellingagentModels = new HashSet<>();
        for (SysSwellingagent sysSwellingagent : listSwellingagentList) {
            String model = sysSwellingagent.getModel();
            if (swellingagentModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                swellingagentList.add(labelValueMap);
            }
        }


        // 创建 idsPlus 并填充数据
        Map<String, Object> idListPlus = new HashMap<>();
        idListPlus.put("regionIdList", listRegionList);
        idListPlus.put("cementIdList", cementIdListPlus);
        idListPlus.put("sandIdList", listSysSandLists);
        idListPlus.put("stoneIdList", listStoneList);
        idListPlus.put("waterReducerList", listWaterList);
        idListPlus.put("flyashIdList", listFlyashList);
        idListPlus.put("efficiencyAgentIdList", efficiencyAgentList);
        idListPlus.put("regionList", "");


        idListPlus.put("waterModel", waterModelList);//水
        idListPlus.put("mineralModel", mineralPowderList);//矿粉
        idListPlus.put("otherAdmixturesModel", otherAdmixturesList);//其他型号
        idListPlus.put("swellingagentModel", swellingagentList);//    //其他型号


        Map<String, Object> result = new HashMap<>();
        // result.put("ids", idList);
        result.put("ids", idListPlus);

        result.put("sliderSection", sliderSection);

        return AjaxResult.success(result);
    }


    /**
     * 原材料下拉框
     *
     * @return
     */
    @GetMapping("/listPullDown")
    public AjaxResult listPullDown() {
        //获取水泥表 型号
        List<SysCement> listCement = sysCementService.list();
        // 使用 Set 保证去重
        Set<String> modelCementSet = listCement.stream()
                .map(SysCement::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> cementModellistVOList = modelCementSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //石头型号
        List<SysStone> listStone = sysStoneService.list();
        // 使用 Set 保证去重
        Set<String> modelStoneSet = listStone.stream()
                .map(SysStone::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> stoneModellistVOList = modelStoneSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //石头规格
        // 使用 Set 保证去重
        Set<String> specificationStoneSet = listStone.stream()
                .map(SysStone::getStoneSpecification) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> specificationlistVOList = specificationStoneSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        HashMap<Object, Object> map = new HashMap<>();


        //砂
        //砂类型
        List<SysSand> listSand = sysSandService.list();
        // 使用 Set 保证去重
        Set<String> sandSet = listSand.stream()
                .map(SysSand::getType) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        // 基于去重后的 model 集合生成 SandFinenessVO 列表
        List<SandFinenessVO> sandTypelistVOList = sandSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //粉煤灰 型号
        List<SysFlyash> listFlyash = sysFlyashService.list();
        // 使用 Set 保证去重
        Set<String> flyashGradelSet = listFlyash.stream()
                .map(SysFlyash::getGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> flyashGradellistVOList = flyashGradelSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //粉煤灰 等级
        Set<String> flyashFactoryGrade = listFlyash.stream()
                .map(SysFlyash::getFactoryGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> flyashFactoryGradelistVOList = flyashFactoryGrade.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //矿粉型号
        List<SysMineralPowder> listMineral = sysMineralPowderService.list();
        Set<String> mineralModel = listMineral.stream()
                .map(SysMineralPowder::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重

        List<SandFinenessVO> mineralModellistVOList = mineralModel.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //矿粉矿渣等级
        Set<String> lagGrade = listMineral.stream()
                .map(SysMineralPowder::getSlagGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> minerallagGradelistVOList = lagGrade.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //石粉 型号
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();

        // 使用 Set 保证去重
        Set<String> OtherAdmixturesSet = listOtherAdmixtures.stream()
                .map(SysOtherAdmixtures::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> otherModellistVOList = OtherAdmixturesSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //  List<SysRegion> regionList = isysRegionService.listRegions();

        //map.put("listRegion", regionList);  //地区

        //水泥
        map.put("cementModel", cementModellistVOList); // 水泥表 类型

        //石头
        map.put("stoneModel", stoneModellistVOList);  //石头类型
        map.put("specificationlist", specificationlistVOList);  //石头规格

        map.put("stoneSpecification", specificationlistVOList); //石头  + 石子规格的参数



        //砂
        map.put("sandTypeOptions", sandTypelistVOList);//砂类型

        //粉煤灰
        map.put("pfaTypeOptions", flyashGradellistVOList); //粉煤灰类型
        map.put("pfaFineOptions", flyashFactoryGradelistVOList); //粉煤灰等级

        //矿粉
        map.put("mineralModel", mineralModellistVOList); //矿粉型号
        map.put("minerallagGrade", minerallagGradelistVOList);//矿粉 矿渣等级


        // 石粉
        map.put("otherAdmixturesModel", otherModellistVOList); //// 其他掺合料型号

        /*------------------------------------------------------------------------------------*/


        Map<String, Object> cementMinAndMax = sysCementService.getCementMinAndMax();
        Map<String, Object> stoneMinAndMax = sysStoneService.getStoneMinAndMax();
        Map<String, Object> flyashMinAndMax = sysFlyashService.queryFlyashMaxMin();
        Map<String, Object> sandMinAndMax = sysSandService.querySandMaxMin();
        Map<String, Object> mineralMinAndMax = sysMineralPowderService.queryMineralMaxMin();
        Map<String, Object> otherMinAndMax = sysOtherAdmixturesService.queryMineralMaxMin();
        /*-----------------------------------------*/


        // 封装砂表数据
        // 石头堆积密度(kg/m³)
        Map<String, Object> stoneStackingDensity = new HashMap<>();
        stoneStackingDensity.put("min", stoneMinAndMax.get("minStackingDensity"));
        stoneStackingDensity.put("max", stoneMinAndMax.get("maxStackingDensity"));

        // 石头 紧密密度(kg/m³)
        Map<String, Object> stoneCompactDensity = new HashMap<>();
        stoneCompactDensity.put("min", stoneMinAndMax.get("minCompactDensity"));
        stoneCompactDensity.put("max", stoneMinAndMax.get("maxCompactDensity"));


        // 石头 表观密度(kg/m³)
        Map<String, Object> stoneBulkDensity = new HashMap<>();
        stoneBulkDensity.put("min", stoneMinAndMax.get("minBulkdensity"));
        stoneBulkDensity.put("max", stoneMinAndMax.get("maxBulkdensity"));


        // 封装水泥表数据
        Map<String, Object> cementCaO = new HashMap<>();
        cementCaO.put("min", cementMinAndMax.get("minCaocontent"));
        cementCaO.put("max", cementMinAndMax.get("maxCaocontent"));

        Map<String, Object> cementSiO2 = new HashMap<>();
        cementSiO2.put("min", cementMinAndMax.get("minSio2content"));
        cementSiO2.put("max", cementMinAndMax.get("maxSio2content"));

        Map<String, Object> cementAl2O3 = new HashMap<>();
        cementAl2O3.put("min", cementMinAndMax.get("minAl2o3content"));
        cementAl2O3.put("max", cementMinAndMax.get("maxAl2o3content"));


        Map<String, Object> cementStrength28d = new HashMap<>();
        cementStrength28d.put("min", cementMinAndMax.get("minCompressiveStrength28d"));
        cementStrength28d.put("max", cementMinAndMax.get("maxCompressiveStrength28d"));

        Map<String, Object> strengthGrade = new HashMap<>();
        strengthGrade.put("min", cementMinAndMax.get("minStrengthGrade"));
        strengthGrade.put("max", cementMinAndMax.get("maxStrengthGrade"));


        //砂
        Map<String, Object> sandFineness = new HashMap<>();     // 砂细度
        sandFineness.put("min", sandMinAndMax.get("minFineness"));
        sandFineness.put("max", sandMinAndMax.get("maxFineness"));


        Map<String, Object> sandBulkDensity = new HashMap<>();     // 砂 堆积密度(kg/m³)
        sandBulkDensity.put("min", sandMinAndMax.get("minBulkDensity"));
        sandBulkDensity.put("max", sandMinAndMax.get("maxBulkDensity"));

        Map<String, Object> sandCompactDensity = new HashMap<>();     // 砂 紧密密度(kg/m³)
        sandCompactDensity.put("min", sandMinAndMax.get("minCompactDensity"));
        sandCompactDensity.put("max", sandMinAndMax.get("maxCompactDensity"));


        Map<String, Object> sandApparentDensity = new HashMap<>();     // 砂 表观密度(kg/m³)
        sandApparentDensity.put("min", sandMinAndMax.get("minApparentDensity"));
        sandApparentDensity.put("max", sandMinAndMax.get("maxApparentDensity"));


        //粉煤灰

        Map<String, Object> flyashFineness = new HashMap<>();     // 煤灰 细度(%)
        flyashFineness.put("min", flyashMinAndMax.get("minFineness"));
        flyashFineness.put("max", flyashMinAndMax.get("maxFineness"));


        Map<String, Object> flyashMoistureContent = new HashMap<>();     // 煤灰 含水量(%)
        flyashMoistureContent.put("min", flyashMinAndMax.get("minMoistureContent"));
        flyashMoistureContent.put("max", flyashMinAndMax.get("maxMoistureContent"));


        Map<String, Object> flyashActivityIndex28d = new HashMap<>();     // 煤灰 28天活性指数(%)
        flyashActivityIndex28d.put("min", flyashMinAndMax.get("minActivityIndex28d"));
        flyashActivityIndex28d.put("max", flyashMinAndMax.get("maxActivityIndex28d"));


        //矿粉
        Map<String, Object> mineralFineness = new HashMap<>();     // 矿粉 细度(%)
        mineralFineness.put("min", mineralMinAndMax.get("minFineness"));
        mineralFineness.put("max", mineralMinAndMax.get("maxFineness"));


        Map<String, Object> mineralMoistureContent = new HashMap<>();     // 矿粉 含水量(%)
        mineralMoistureContent.put("min", mineralMinAndMax.get("minMoistureContent"));
        mineralMoistureContent.put("max", mineralMinAndMax.get("maxMoistureContent"));


        Map<String, Object> mineralActivityIndex28d = new HashMap<>();     // 矿粉 28天活性指数(%)
        mineralActivityIndex28d.put("min", mineralMinAndMax.get("minActivityIndex28d"));
        mineralActivityIndex28d.put("max", mineralMinAndMax.get("maxActivityIndex28d"));


        // 其他掺合料
        Map<String, Object> otherFineness = new HashMap<>();     // 其他掺合料 细度
        otherFineness.put("min", otherMinAndMax.get("minFineness"));
        otherFineness.put("max", otherMinAndMax.get("maxFineness"));


        Map<String, Object> otherMoistureContent = new HashMap<>();     // 其他掺合料 含水量(%)
        otherMoistureContent.put("min", otherMinAndMax.get("minMoistureContent"));
        otherMoistureContent.put("max", otherMinAndMax.get("maxMoistureContent"));

        Map<String, Object> otherActivityIndex28d = new HashMap<>();     // 其他掺合料 28天活性指数(%)
        otherActivityIndex28d.put("min", otherMinAndMax.get("minActivityIndex28d"));
        otherActivityIndex28d.put("max", otherMinAndMax.get("maxActivityIndex28d"));


        // 返回整体结果
        Map<String, Object> result = new HashMap<>();


        // 水泥
        result.put("cementCaO", cementCaO); //水泥 CaO含量（%）
        result.put("cementSiO2", cementSiO2); //水泥 SiO2含量（%）
        result.put("cementAl2O3", cementAl2O3); //水泥 Al2O3含量（%）
        result.put("cementStrength28d", cementStrength28d); //水泥 28天抗压强度(MPa)
        result.put("strengthGrade", strengthGrade); //水泥 强度等级


        //石头
        result.put("stoneStackingDensity", stoneStackingDensity); //石头 堆积密度(kg/m³)
        result.put("stoneCompactDensity", stoneCompactDensity); //石头 紧密密度(kg/m³)
        result.put("stoneBulkDensity", stoneBulkDensity); //石头  表观密度


        // 砂
        result.put("sandFineness", sandFineness); //砂 砂细度
        result.put("sandBulkDensity", sandBulkDensity); //砂    堆积密度(kg/m³)
        result.put("sandCompactDensity", sandCompactDensity); //砂      紧密密度(kg/m³)
        result.put("sandApparentDensity", sandApparentDensity); //砂  表观密度(kg/m³)


        //煤灰
        result.put("flyashFineness", flyashFineness); // 煤灰 细度(%)
        result.put("flyashMoistureContent", flyashMoistureContent);  // 煤灰 含水量(%)
        result.put("flyashActivityIndex28d", flyashActivityIndex28d); // 煤灰 28天活性指数(%)


        //矿粉
        result.put("mineralFineness", mineralFineness);  // 矿粉 细度(%)
        result.put("mineralMoistureContent", mineralMoistureContent); // 矿粉 含水量(%)
        result.put("mineralActivityIndex28d", mineralActivityIndex28d);// 矿粉 28天活性指数(%)


        //其他参合料(石粉)
        result.put("otherFineness", otherFineness);// 其他掺合料 细度
        result.put("otherMoistureContent", otherMoistureContent);// 其他掺合料 含水量(%)
        result.put("otherActivityIndex28d", otherActivityIndex28d);// 其他掺合料 28天活性指数(%)


        map.put("sliderSection", result); // 最大值 最小值


        return AjaxResult.success(map);
    }


    /**
     * 查询外加剂下拉框
     *
     * @return
     */
    @GetMapping("/listAdditivePullDown")
    public AjaxResult listAdditivePullDown() {

        //减水剂型号
        List<SysWaterReducer> listWaterReducer = sysWaterReducerService.list();
        Set<String> waterReducerSet = listWaterReducer.stream()
                .map(SysWaterReducer::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> wateModellistVOList = waterReducerSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //减水剂商家
        Set<String> waterSourceName = listWaterReducer.stream()
                .map(SysWaterReducer::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> waterSourceNameVOList = waterSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());
        //增效剂型号
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
        Set<String> efficiencyAgentSet = listEfficiencyAgent.stream()
                .map(SysEfficiencyAgent::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> agentModel = efficiencyAgentSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //增效剂商家
        Set<String> agentSourceName = listEfficiencyAgent.stream()
                .map(SysEfficiencyAgent::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> agentSourceNameVOList = agentSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //膨胀剂型号
        List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
        Set<String> swellingagentSet = listSwellingagent.stream()
                .map(SysSwellingagent::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> swellingagentModel = swellingagentSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //膨胀剂商家
        Set<String> sysSwellingagentSourceName = listSwellingagent.stream()
                .map(SysSwellingagent::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> sysSwellingagentSourceNameVOList = sysSwellingagentSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        HashMap<Object, Object> map = new HashMap<>();
        //减水剂
        map.put("waterReducerModel", wateModellistVOList);//减水剂型号
        map.put("waterSourceName", waterSourceNameVOList); //减水剂商家


        //增效剂
        map.put("agentModel", agentModel);//增效剂型号
        map.put("agentSourceName", agentSourceNameVOList); //增效剂商家


        //膨胀剂
        map.put("swellingagentModel", swellingagentModel);//膨胀剂型号
        map.put("swellingagentSource", sysSwellingagentSourceNameVOList); //膨胀剂商家


        //获取减水剂
        Map<String, Object> waterReducerMinAndMax = sysWaterReducerService.getwaterReducerAndMax();

        // 返回整体结果
        Map<String, Object> result = new HashMap<>();
        // 含固量
        Map<String, Object> solidContent = new HashMap<>();
        solidContent.put("min", waterReducerMinAndMax.get("minSolidContent"));
        solidContent.put("max", waterReducerMinAndMax.get("maxSolidContent"));

        //减水率%
        Map<String, Object> reducingRate = new HashMap<>();
        reducingRate.put("min", waterReducerMinAndMax.get("minReducingRate"));
        reducingRate.put("max", waterReducerMinAndMax.get("maxReducingRate"));

        //水泥净浆流动度(mm)
        Map<String, Object> reducingCementPasteFlow = new HashMap<>();
        reducingCementPasteFlow.put("min", waterReducerMinAndMax.get("minCementPasteFlow"));
        reducingCementPasteFlow.put("max", waterReducerMinAndMax.get("maxCementPasteFlow"));


        //减水剂
        result.put("solidContent", solidContent); // 含固量
        result.put("reducingRate", reducingRate); //减水率%
        result.put("reducingCementPasteFlow", reducingCementPasteFlow);//水泥净浆流动度


        map.put("sliderSection", result); // 最大值 最小值
        return AjaxResult.success(map);
    }





/*
    @GetMapping("/listMechanicalPerformancePullDown")
    public AjaxResult listMechanicalPerformancePullDown() {
        // 获取从数据库中查询到的最大值和最小值
        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> compressiveStrength7d = new HashMap<>();
        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));

        Map<String, Object> compressiveStrength28d = new HashMap<>();
        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", efficiencyMerchantMinAndMax.get("minWaterContent"));
        waterContent.put("max", efficiencyMerchantMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", efficiencyMerchantMinAndMax.get("minCementContent"));
        cementContent.put("max", efficiencyMerchantMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", efficiencyMerchantMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", efficiencyMerchantMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", efficiencyMerchantMinAndMax.get("minSandContent"));
        sandContent.put("max", efficiencyMerchantMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", efficiencyMerchantMinAndMax.get("minStoneContent"));
        stoneContent.put("max", efficiencyMerchantMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducerDosage"));

        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", efficiencyMerchantMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", efficiencyMerchantMinAndMax.get("maxEfficiencyAgentDosage"));


        Map<String, Object> waterDosage = new HashMap<>();
        waterDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterDosage"));
        waterDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterDosage"));

        Map<String, Object> powderDosage = new HashMap<>();
        powderDosage.put("min", efficiencyMerchantMinAndMax.get("minPowderDosage"));
        powderDosage.put("max", efficiencyMerchantMinAndMax.get("maxPowderDosage"));


        Map<String, Object> admixturesDosage = new HashMap<>();
        admixturesDosage.put("min", efficiencyMerchantMinAndMax.get("minAdmixturesDosage"));
        admixturesDosage.put("max", efficiencyMerchantMinAndMax.get("maxAdmixturesDosage"));



        Map<String, Object> swellingagentDosage = new HashMap<>();
        swellingagentDosage.put("min", efficiencyMerchantMinAndMax.get("minSwellingagentDosage"));
        swellingagentDosage.put("max", efficiencyMerchantMinAndMax.get("maxSwellingagentDosage"));



        // 获取ID列表并转换为所需格式
        Function<List<Integer>, List<Map<String, String>>> convertToValueLabelList = list ->
                list.stream()
                        .map(id -> {
                            Map<String, String> item = new HashMap<>();
                            item.put("value", String.valueOf(id));
                            item.put("label", String.valueOf(id));
                            return item;
                        })
                        .collect(Collectors.toList());

        List<Map<String, String>> regionIdList = convertToValueLabelList.apply(
                isysRegionService.listRegions().stream().map(SysRegion::getRegionId).collect(Collectors.toList())
        );

        List<Map<String, String>> cementIdList = convertToValueLabelList.apply(
                sysCementService.listCement().stream().map(SysCement::getCementId).collect(Collectors.toList())
        );
        System.out.println("哈哈哈"+cementIdList);


        List<Map<String, String>> sandIdList = convertToValueLabelList.apply(
                sysSandService.listSand().stream().map(SysSand::getSandId).collect(Collectors.toList())
        );

        List<Map<String, String>> stoneIdList = convertToValueLabelList.apply(
                sysStoneService.listStones().stream()
                        .map(SysStone::getStoneId)
                        .collect(Collectors.toList())


        );

        List<Map<String, String>> waterReducerList = convertToValueLabelList.apply(
                sysWaterReducerService.listWaterReduce().stream()
                        .map(reducer -> reducer.getReducerId().intValue())
                        .collect(Collectors.toList())
        );

        List<Map<String, String>> flyashIdList = convertToValueLabelList.apply(
                sysFlyashService.listFlyash().stream().map(SysFlyash::getFlyashId).collect(Collectors.toList())
        );

        List<Map<String, String>> efficiencyAgentIdList = convertToValueLabelList.apply(
                sysEfficiencyAgent.listefficiencyAgents().stream()
                        .map(agent -> agent.getAgentId().intValue())
                        .collect(Collectors.toList())
        );



        List<SysRegion> regionList = isysRegionService.listRegions();

        Map<String, Object> idList = new HashMap<>();
        idList.put("regionIdList", regionIdList);
        idList.put("cementIdList", cementIdList);
        idList.put("sandIdList", sandIdList);
        idList.put("stoneIdList", stoneIdList);
        idList.put("waterReducerList", waterReducerList);
        idList.put("flyashIdList", flyashIdList);
        idList.put("efficiencyAgentIdList", efficiencyAgentIdList);
        idList.put("regionList", regionList);

      //  idList.put("waterModelList", waterModelList);//水型号


        // 构建返回结果
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("compressive7d", compressiveStrength7d);
        sliderSection.put("compressive28d", compressiveStrength28d);
        sliderSection.put("waterContent", waterContent);
        sliderSection.put("cementContent", cementContent);
        sliderSection.put("flyAshContent", flyAshContent);
        sliderSection.put("sandContent", sandContent);
        sliderSection.put("stoneContent", stoneContent);
        sliderSection.put("waterReducerDosage", waterReducerDosage);
        sliderSection.put("synergyDosage", efficiencyAgentDosage);

        sliderSection.put("waterDosage", waterDosage);//水掺量（%）
        sliderSection.put("powderDosage", powderDosage);///矿粉掺量
        sliderSection.put("admixturesDosage", admixturesDosage);//其他参合料掺量
        sliderSection.put("swellingagentDosage", swellingagentDosage);//膨胀剂掺量



*/
/*
        // 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        for (SysCement sysCement : sysCementList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysCement.getModel());
            labelValueMap.put("value", sysCement.getModel());
            cementIdListPlus.add(labelValueMap);
        }

        // 地区
        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionName());
            labelValueMap.put("value", sysRegion.getRegionName());

            listRegionList.add(labelValueMap);
        }


        List<SysSand> listSysSands = sysSandService.listSand();

        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        for (SysSand sysRegion : listSysSands) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getType());
            labelValueMap.put("value", sysRegion.getType());

            listSysSandLists.add(labelValueMap);
        }

        //石头
        List<SysStone> sysStoneList = sysStoneService.listStones();

        List<Map<String, Object>> listStoneList = new ArrayList<>();
        for (SysStone sysStone : sysStoneList) {
            Map<String, Object> labelStoneValueMaps = new HashMap<>();
            labelStoneValueMaps.put("label", sysStone.getParticleSizeDistribution());
            labelStoneValueMaps.put("value", sysStone.getParticleSizeDistribution());
            listStoneList.add(labelStoneValueMaps);
        }

        //减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        for (SysWaterReducer reducer : reducers) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", reducer.getModel());
            labelValueMap.put("value", reducer.getModel());
            listWaterList.add(labelValueMap);
        }

        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysFlyash.getGrade());
            labelValueMap.put("value", sysFlyash.getGrade());
            listFlyashList.add(labelValueMap);

        }


        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();

        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", efficiencyAgent.getModel());
            labelValueMap.put("value", efficiencyAgent.getModel());
            efficiencyAgentList.add(labelValueMap);
        }

        // 水型号
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        List<SysWater> listWaterModelList = waterService.list();
        for (SysWater sysWater : listWaterModelList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }
        //矿粉型号
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        for (SysMineralPowder sysWater : listMineralPowderList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            mineralPowderList.add(labelValueMap);

        }

        //其他型号
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        for (SysOtherAdmixtures sysWater : listOtherAdmixturesList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }

        //膨胀剂型号
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        for (SysSwellingagent sysWater : listSwellingagentList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            swellingagentList.add(labelValueMap);

        }*//*







// 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        Set<String> cementModels = new HashSet<>();
        for (SysCement sysCement : sysCementList) {
            String model = sysCement.getModel();
            if (cementModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                cementIdListPlus.add(labelValueMap);
            }
        }


        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionId());
            labelValueMap.put("value", sysRegion.getRegionName());
            listRegionList.add(labelValueMap);
        }

// 砂类型
        List<SysSand> listSysSands = sysSandService.listSand();
        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        Set<String> sandTypes = new HashSet<>();
        for (SysSand sysSand : listSysSands) {
            String type = sysSand.getType();
            if (sandTypes.add(type)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", type);
                labelValueMap.put("value", type);
                listSysSandLists.add(labelValueMap);
            }
        }

// 石头类型
        List<SysStone> sysStoneList = sysStoneService.listStones();
        List<Map<String, Object>> listStoneList = new ArrayList<>();
        Set<String> stoneDistributions = new HashSet<>();
*/
/*        for (SysStone sysStone : sysStoneList) {
            String distribution = sysStone.getParticleSizeDistribution();
            if (stoneDistributions.add(distribution)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", distribution);
                labelValueMap.put("value", distribution);
                listStoneList.add(labelValueMap);
            }
        }*//*


// 减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        Set<String> waterReducerModels = new HashSet<>();
        for (SysWaterReducer reducer : reducers) {
            String model = reducer.getModel();
            if (waterReducerModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                listWaterList.add(labelValueMap);
            }
        }

// 粉煤灰
        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        Set<String> flyashGrades = new HashSet<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            String grade = sysFlyash.getGrade();
            if (flyashGrades.add(grade)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", grade);
                labelValueMap.put("value", grade);
                listFlyashList.add(labelValueMap);
            }
        }

// 高效剂
        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();
        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        Set<String> efficiencyAgentModels = new HashSet<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            String model = efficiencyAgent.getModel();
            if (efficiencyAgentModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                efficiencyAgentList.add(labelValueMap);
            }
        }

// 水型号
        List<SysWater> listWaterModelList = waterService.list();
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        Set<String> waterModels = new HashSet<>();
        for (SysWater sysWater : listWaterModelList) {
            String model = sysWater.getModel();
            if (waterModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                waterModelList.add(labelValueMap);
            }
        }

// 矿粉型号
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        Set<String> mineralPowderModels = new HashSet<>();
        for (SysMineralPowder sysMineralPowder : listMineralPowderList) {
            String model = sysMineralPowder.getModel();
            if (mineralPowderModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                mineralPowderList.add(labelValueMap);
            }
        }

// 其他型号
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        Set<String> otherAdmixtureModels = new HashSet<>();
        for (SysOtherAdmixtures sysOtherAdmixtures : listOtherAdmixturesList) {
            String model = sysOtherAdmixtures.getModel();
            if (otherAdmixtureModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                otherAdmixturesList.add(labelValueMap);
            }
        }

// 膨胀剂型号
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        Set<String> swellingagentModels = new HashSet<>();
        for (SysSwellingagent sysSwellingagent : listSwellingagentList) {
            String model = sysSwellingagent.getModel();
            if (swellingagentModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                swellingagentList.add(labelValueMap);
            }
        }



        // 创建 idsPlus 并填充数据
        Map<String, Object> idListPlus = new HashMap<>();
        idListPlus.put("regionIdList", listRegionList);
        idListPlus.put("cementIdList", cementIdListPlus);
        idListPlus.put("sandIdList", listSysSandLists);
        idListPlus.put("stoneIdList", listStoneList);
        idListPlus.put("waterReducerList", listWaterList);
        idListPlus.put("flyashIdList", listFlyashList);
        idListPlus.put("efficiencyAgentIdList", efficiencyAgentList);
        idListPlus.put("regionList", "");

        idListPlus.put("waterModel", waterModelList);//水
        idListPlus.put("mineralModel",mineralPowderList );//矿粉
        idListPlus.put("otherAdmixturesModel", otherAdmixturesList);//其他型号
        idListPlus.put("swellingagentModel",swellingagentList );//    //其他型号


        Map<String, Object> result = new HashMap<>();
        // result.put("ids", idList);
        result.put("sliderSection", sliderSection);
        result.put("ids", idListPlus);
        return AjaxResult.success(result);


    }
*/


    /**
     * 查询力学性能最大值 最小值
     * @return
     */

/*
    @GetMapping("/listMechanicalPerformancePullDown")
    public AjaxResult listMechanicalPerformancePullDown() {

        // 获取从数据库中查询到的最大值和最小值
        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> compressiveStrength7d = new HashMap<>();
        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));

        Map<String, Object> compressiveStrength28d = new HashMap<>();
        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", efficiencyMerchantMinAndMax.get("minWaterContent"));
        waterContent.put("max", efficiencyMerchantMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", efficiencyMerchantMinAndMax.get("minCementContent"));
        cementContent.put("max", efficiencyMerchantMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", efficiencyMerchantMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", efficiencyMerchantMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", efficiencyMerchantMinAndMax.get("minSandContent"));
        sandContent.put("max", efficiencyMerchantMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", efficiencyMerchantMinAndMax.get("minStoneContent"));
        stoneContent.put("max", efficiencyMerchantMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducerDosage"));
        HashMap<Object, Object> map = new HashMap<>();



        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", efficiencyMerchantMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", efficiencyMerchantMinAndMax.get("maxEfficiencyAgentDosage"));




        // 获取地区列表id列表
        List<SysRegion> regionList = isysRegionService.listRegions();
        List<Integer> regionIdList = regionList.stream()
                .map(SysRegion::getRegionId)
                .collect(Collectors.toList());






        //获取水泥id列表
        List<SysCement> sysCementList  = sysCementService.listCement();
        List<Integer> cementIdList = sysCementList.stream()
                .map(SysCement::getCementId)
                .collect(Collectors.toList());


        //砂 id列表
        List<SysSand> sysSands = sysSandService.listSand();
        List<Integer> sysSandIdList = sysSands.stream()
                .map(SysSand::getSandId)
                .collect(Collectors.toList());


        //石头
        List<SysStone> sysStoneList = sysStoneService.listStones();
        List<Integer> stoneIdList = sysStoneList.stream()
                .map(SysStone::getStoneId)
                .collect(Collectors.toList());

        //减水剂id列表
        List<SysWaterReducer> sysWaterReducerList = sysWaterReducerService.listWaterReduce();
        List<Integer> waterReducerList = sysWaterReducerList.stream()
                .map(reducer -> reducer.getReducerId().intValue()) // 使用 intValue() 方法进行转换
                .collect(Collectors.toList());

        //粉煤灰
        List<SysFlyash> flyashList = sysFlyashService.listFlyash();
        List<Integer>flyashIdList = flyashList.stream()
                .map(SysFlyash::getFlyashId)
                .collect(Collectors.toList());

        List<SysEfficiencyAgent> sysEfficiencyAgentList = sysEfficiencyAgent.listefficiencyAgents();
        List<Integer> efficiencyAgentIdList = sysEfficiencyAgentList.stream()
                .map(agent -> agent.getAgentId().intValue()) // Convert Long to Integer
                .collect(Collectors.toList());






        HashMap<Object, Object> idList = new HashMap<>();
        idList.put("regionIdList",regionIdList);
        idList.put("cementIdList",cementIdList);
        idList.put("sandIdList",sysSandIdList);
        idList.put("stoneIdList",stoneIdList);
        idList.put("waterReducerList",waterReducerList);
        idList.put("flyashIdList",flyashIdList);
        idList.put("efficiencyAgentIdList",efficiencyAgentIdList);


        // 将所有的结果封装到最终的返回 Map 中
        Map<String, Object> result = new HashMap<>();
        result.put("compressive7d", compressiveStrength7d);
        result.put("compressive28d", compressiveStrength28d);
        result.put("waterContent", waterContent);
        result.put("cementContent", cementContent);
        result.put("flyAshContent", flyAshContent);
        result.put("sandContent", sandContent);
        result.put("stoneContent", stoneContent);
        result.put("waterDosage", waterReducerDosage);
        map.put("sliderSection",result);
        result.put("synergyDosage", efficiencyAgentDosage);

        map.put("ids",idList);
        return AjaxResult.success(map);
    }
*/

    /**
     * 力学性能下拉框
     * @return
     */
//    @GetMapping("/listMechanicalPerformancePullDown")
//    public AjaxResult listMechanicalPerformancePullDown() {
//
//        // 获取从数据库中查询到的最大值和最小值
//        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();
//
//        // 构建每个字段的最小值和最大值
//        Map<String, Object> compressiveStrength7d = new HashMap<>();
//        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
//        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));
//
//        Map<String, Object> compressiveStrength28d = new HashMap<>();
//        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
//        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));
//
//        Map<String, Object> waterContent = new HashMap<>();
//        waterContent.put("min", efficiencyMerchantMinAndMax.get("minWaterContent"));
//        waterContent.put("max", efficiencyMerchantMinAndMax.get("maxWaterContent"));
//
//        Map<String, Object> cementContent = new HashMap<>();
//        cementContent.put("min", efficiencyMerchantMinAndMax.get("minCementContent"));
//        cementContent.put("max", efficiencyMerchantMinAndMax.get("maxCementContent"));
//
//        Map<String, Object> flyAshContent = new HashMap<>();
//        flyAshContent.put("min", efficiencyMerchantMinAndMax.get("minFlyAshContent"));
//        flyAshContent.put("max", efficiencyMerchantMinAndMax.get("maxFlyAshContent"));
//
//        Map<String, Object> sandContent = new HashMap<>();
//        sandContent.put("min", efficiencyMerchantMinAndMax.get("minSandContent"));
//        sandContent.put("max", efficiencyMerchantMinAndMax.get("maxSandContent"));
//
//        Map<String, Object> stoneContent = new HashMap<>();
//        stoneContent.put("min", efficiencyMerchantMinAndMax.get("minStoneContent"));
//        stoneContent.put("max", efficiencyMerchantMinAndMax.get("maxStoneContent"));
//
//        Map<String, Object> waterReducerDosage = new HashMap<>();
//        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterReducerDosage"));
//        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducerDosage"));
//        HashMap<Object, Object> map = new HashMap<>();
//
//        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
//        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("maxEfficiencyAgentDosage"));
//        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("minEfficiencyAgentDosage"));
//
//
//
//
//        // 获取地区列表id列表
//        List<SysRegion> regionList = isysRegionService.listRegions();
//        List<Integer> regionIdList = regionList.stream()
//                .map(SysRegion::getRegionId)
//                .collect(Collectors.toList());
//
//          //获取水泥id列表
//        List<SysCement> sysCementList  = sysCementService.listCement();
//        List<Integer> cementIdList = sysCementList.stream()
//                .map(SysCement::getCementId)
//                .collect(Collectors.toList());
//
//
//        //砂 id列表
//        List<SysSand> sysSands = sysSandService.listSand();
//        List<Integer> sysSandIdList = sysSands.stream()
//                .map(SysSand::getSandId)
//                .collect(Collectors.toList());
//
//
//        //石头
//        List<SysStone> sysStoneList = sysStoneService.listStones();
//        List<Integer> stoneIdList = sysStoneList.stream()
//                .map(SysStone::getStoneId)
//                .collect(Collectors.toList());
//
//        //减水剂id列表
//        List<SysWaterReducer> sysWaterReducerList = sysWaterReducerService.listWaterReduce();
//        List<Integer> waterReducerList = sysWaterReducerList.stream()
//                .map(reducer -> reducer.getReducerId().intValue()) // 使用 intValue() 方法进行转换
//                .collect(Collectors.toList());
//
//        //粉煤灰
//        List<SysFlyash> flyashList = sysFlyashService.listFlyash();
//        List<Integer>flyashIdList = flyashList.stream()
//                .map(SysFlyash::getFlyashId)
//                .collect(Collectors.toList());
//
//
//
//        HashMap<Object, Object> idList = new HashMap<>();
//        idList.put("regionIdList",regionIdList);
//        idList.put("cementIdList",cementIdList);
//        idList.put("sandIdList",sysSandIdList);
//        idList.put("stoneIdList",stoneIdList);
//        idList.put("waterReducerList",waterReducerList);
//        idList.put("flyashIdList",flyashIdList);
//
//        // 将所有的结果封装到最终的返回 Map 中
//        Map<String, Object> result = new HashMap<>();
//        result.put("compressive7d", compressiveStrength7d);
//        result.put("compressive28d", compressiveStrength28d);
//        result.put("waterContent", waterContent);
//        result.put("cementContent", cementContent);
//        result.put("flyAshContent", flyAshContent);
//        result.put("sandContent", sandContent);
//        result.put("stoneContent", stoneContent);
//        result.put("waterDosage", waterReducerDosage);
//        map.put("sliderSection",result);
//        result.put("synergyDosage", efficiencyAgentDosage);
//
//
//        map.put("ids",idList);
//        return AjaxResult.success(map);
//    }


    /**
     * 查询外加剂原材料信息
     */

//    @GetMapping("/listAdditivePullDown")
//    public AjaxResult listAdditivePullDown() {
//
//        List<SysWaterReducer> waterReducerList = sysWaterReducerService.listWaterReduce();
//        List<SandFinenessVO> sysFlyashFinenessesVOList = waterReducerList.stream()
//                .map(s -> {
//                    SandFinenessVO vo = new SandFinenessVO();
//                    vo.setValue(s.getSourceName());
//                    vo.setLabel(s.getSourceName());
//                    return vo;
//                })
//                .collect(Collectors.toList());
//
//
//        HashMap<Object, Object> map = new HashMap<>();
//        map.put("waterReducerOptions", sysFlyashFinenessesVOList);
//
//        return AjaxResult.success(map);
//    }


    /**
     * 导出原材料excel
     */
//    @PostMapping("exportRawMaterialsExcel")
//    public AjaxResult exportRawMaterialsExcel(@RequestBody RawMaterialsDTO rawMaterialsDTO){
//        List<Integer> cementIds = rawMaterialsDTO.getCementIds();
//     List<SysCement> listCementList=   sysCementService.listCementByIds(cementIds);
//
//
//
//
//        // 创建一个 Excel 工作簿
//        Workbook workbook = new XSSFWorkbook();
//        // 创建一个 Sheet，并命名为 "水泥"
//        Sheet sheet = workbook.createSheet("水泥");
//
//
//
//
//
//        return AjaxResult.success(listCementList);
//    }


//    /**
//     * 查询力学性能最大值最小值
//     * @param
//     * @return
//     */
//    @GetMapping("/listMechanicalPerformancePullDown")
//    public AjaxResult listMechanicalPerformancePullDown() {
//
//
//
//        Map<String, Object> result = new HashMap<>();
//        // result.put("ids", idList);
//        result.put("sliderSection", sliderSection);
//        result.put("ids", idListPlus);
//    }


/*
    @GetMapping("/listMechanicalPerformancePullDown")
    public AjaxResult listMechanicalPerformancePullDown() {
        // 获取从数据库中查询到的最大值和最小值
        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();

        // 构建每个字段的最小值和最大值
        Map<String, Object> compressiveStrength7d = new HashMap<>();
        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));

        Map<String, Object> compressiveStrength28d = new HashMap<>();
        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));

        Map<String, Object> waterContent = new HashMap<>();
        waterContent.put("min", efficiencyMerchantMinAndMax.get("minWaterContent"));
        waterContent.put("max", efficiencyMerchantMinAndMax.get("maxWaterContent"));

        Map<String, Object> cementContent = new HashMap<>();
        cementContent.put("min", efficiencyMerchantMinAndMax.get("minCementContent"));
        cementContent.put("max", efficiencyMerchantMinAndMax.get("maxCementContent"));

        Map<String, Object> flyAshContent = new HashMap<>();
        flyAshContent.put("min", efficiencyMerchantMinAndMax.get("minFlyAshContent"));
        flyAshContent.put("max", efficiencyMerchantMinAndMax.get("maxFlyAshContent"));

        Map<String, Object> sandContent = new HashMap<>();
        sandContent.put("min", efficiencyMerchantMinAndMax.get("minSandContent"));
        sandContent.put("max", efficiencyMerchantMinAndMax.get("maxSandContent"));

        Map<String, Object> stoneContent = new HashMap<>();
        stoneContent.put("min", efficiencyMerchantMinAndMax.get("minStoneContent"));
        stoneContent.put("max", efficiencyMerchantMinAndMax.get("maxStoneContent"));

        Map<String, Object> waterReducerDosage = new HashMap<>();
        waterReducerDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterReducerDosage"));
        waterReducerDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducerDosage"));

        Map<String, Object> efficiencyAgentDosage = new HashMap<>();
        efficiencyAgentDosage.put("min", efficiencyMerchantMinAndMax.get("minEfficiencyAgentDosage"));
        efficiencyAgentDosage.put("max", efficiencyMerchantMinAndMax.get("maxEfficiencyAgentDosage"));


        Map<String, Object> waterDosage = new HashMap<>();
        waterDosage.put("min", efficiencyMerchantMinAndMax.get("minWaterDosage"));
        waterDosage.put("max", efficiencyMerchantMinAndMax.get("maxWaterDosage"));

        Map<String, Object> powderDosage = new HashMap<>();
        powderDosage.put("min", efficiencyMerchantMinAndMax.get("minPowderDosage"));
        powderDosage.put("max", efficiencyMerchantMinAndMax.get("maxPowderDosage"));


        Map<String, Object> admixturesDosage = new HashMap<>();
        admixturesDosage.put("min", efficiencyMerchantMinAndMax.get("minAdmixturesDosage"));
        admixturesDosage.put("max", efficiencyMerchantMinAndMax.get("maxAdmixturesDosage"));



        Map<String, Object> swellingagentDosage = new HashMap<>();
        swellingagentDosage.put("min", efficiencyMerchantMinAndMax.get("minSwellingagentDosage"));
        swellingagentDosage.put("max", efficiencyMerchantMinAndMax.get("maxSwellingagentDosage"));



        // 获取ID列表并转换为所需格式
        Function<List<Integer>, List<Map<String, String>>> convertToValueLabelList = list ->
                list.stream()
                        .map(id -> {
                            Map<String, String> item = new HashMap<>();
                            item.put("value", String.valueOf(id));
                            item.put("label", String.valueOf(id));
                            return item;
                        })
                        .collect(Collectors.toList());

        List<Map<String, String>> regionIdList = convertToValueLabelList.apply(
                isysRegionService.listRegions().stream().map(SysRegion::getRegionId).collect(Collectors.toList())
        );

        List<Map<String, String>> cementIdList = convertToValueLabelList.apply(
                sysCementService.listCement().stream().map(SysCement::getCementId).collect(Collectors.toList())
        );
        System.out.println("哈哈哈"+cementIdList);


        List<Map<String, String>> sandIdList = convertToValueLabelList.apply(
                sysSandService.listSand().stream().map(SysSand::getSandId).collect(Collectors.toList())
        );

        List<Map<String, String>> stoneIdList = convertToValueLabelList.apply(
                sysStoneService.listStones().stream()
                        .map(SysStone::getStoneId)
                        .collect(Collectors.toList())


        );

        List<Map<String, String>> waterReducerList = convertToValueLabelList.apply(
                sysWaterReducerService.listWaterReduce().stream()
                        .map(reducer -> reducer.getReducerId().intValue())
                        .collect(Collectors.toList())
        );

        List<Map<String, String>> flyashIdList = convertToValueLabelList.apply(
                sysFlyashService.listFlyash().stream().map(SysFlyash::getFlyashId).collect(Collectors.toList())
        );

        List<Map<String, String>> efficiencyAgentIdList = convertToValueLabelList.apply(
                sysEfficiencyAgent.listefficiencyAgents().stream()
                        .map(agent -> agent.getAgentId().intValue())
                        .collect(Collectors.toList())
        );




        List<SysRegion> regionList = isysRegionService.listRegions();

        Map<String, Object> idList = new HashMap<>();
        idList.put("regionIdList", regionIdList);
        idList.put("cementIdList", cementIdList);
        idList.put("sandIdList", sandIdList);
        idList.put("stoneIdList", stoneIdList);
        idList.put("waterReducerList", waterReducerList);
        idList.put("flyashIdList", flyashIdList);
        idList.put("efficiencyAgentIdList", efficiencyAgentIdList);
        idList.put("regionList", regionList);

        //  idList.put("waterModelList", waterModelList);//水型号







        // 构建返回结果
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("compressive7d", compressiveStrength7d);
        sliderSection.put("compressive28d", compressiveStrength28d);
        sliderSection.put("waterContent", waterContent);
        sliderSection.put("cementContent", cementContent);
        sliderSection.put("flyAshContent", flyAshContent);
        sliderSection.put("sandContent", sandContent);
        sliderSection.put("stoneContent", stoneContent);
        sliderSection.put("waterReducerDosage", waterReducerDosage);
        sliderSection.put("synergyDosage", efficiencyAgentDosage);

        sliderSection.put("waterDosage", waterDosage);//水掺量（%）
        sliderSection.put("powderDosage", powderDosage);///矿粉掺量
        sliderSection.put("admixturesDosage", admixturesDosage);//其他参合料掺量
        sliderSection.put("swellingagentDosage", swellingagentDosage);//膨胀剂掺量




*/
/*
        // 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        for (SysCement sysCement : sysCementList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysCement.getModel());
            labelValueMap.put("value", sysCement.getModel());
            cementIdListPlus.add(labelValueMap);
        }

        // 地区
        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionName());
            labelValueMap.put("value", sysRegion.getRegionName());

            listRegionList.add(labelValueMap);
        }


        List<SysSand> listSysSands = sysSandService.listSand();

        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        for (SysSand sysRegion : listSysSands) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getType());
            labelValueMap.put("value", sysRegion.getType());

            listSysSandLists.add(labelValueMap);
        }

        //石头
        List<SysStone> sysStoneList = sysStoneService.listStones();

        List<Map<String, Object>> listStoneList = new ArrayList<>();
        for (SysStone sysStone : sysStoneList) {
            Map<String, Object> labelStoneValueMaps = new HashMap<>();
            labelStoneValueMaps.put("label", sysStone.getParticleSizeDistribution());
            labelStoneValueMaps.put("value", sysStone.getParticleSizeDistribution());
            listStoneList.add(labelStoneValueMaps);
        }

        //减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        for (SysWaterReducer reducer : reducers) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", reducer.getModel());
            labelValueMap.put("value", reducer.getModel());
            listWaterList.add(labelValueMap);
        }

        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysFlyash.getGrade());
            labelValueMap.put("value", sysFlyash.getGrade());
            listFlyashList.add(labelValueMap);

        }


        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();

        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", efficiencyAgent.getModel());
            labelValueMap.put("value", efficiencyAgent.getModel());
            efficiencyAgentList.add(labelValueMap);
        }

        // 水型号
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        List<SysWater> listWaterModelList = waterService.list();
        for (SysWater sysWater : listWaterModelList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }
        //矿粉型号
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        for (SysMineralPowder sysWater : listMineralPowderList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            mineralPowderList.add(labelValueMap);

        }

        //其他型号
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        for (SysOtherAdmixtures sysWater : listOtherAdmixturesList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            waterModelList.add(labelValueMap);

        }

        //膨胀剂型号
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        for (SysSwellingagent sysWater : listSwellingagentList) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysWater.getModel());
            labelValueMap.put("value", sysWater.getModel());
            swellingagentList.add(labelValueMap);

        }*//*







// 水泥
        List<SysCement> sysCementList = sysCementService.listCement();
        List<Map<String, Object>> cementIdListPlus = new ArrayList<>();
        Set<String> cementModels = new HashSet<>();
        for (SysCement sysCement : sysCementList) {
            String model = sysCement.getModel();
            if (cementModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                cementIdListPlus.add(labelValueMap);
            }
        }


        List<SysRegion> listRegion = isysRegionService.listRegions();
        List<Map<String, Object>> listRegionList = new ArrayList<>();
        for (SysRegion sysRegion : listRegion) {
            Map<String, Object> labelValueMap = new HashMap<>();
            labelValueMap.put("label", sysRegion.getRegionId());
            labelValueMap.put("value", sysRegion.getRegionName());
            listRegionList.add(labelValueMap);
        }

// 砂类型
        List<SysSand> listSysSands = sysSandService.listSand();
        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        Set<String> sandTypes = new HashSet<>();
        for (SysSand sysSand : listSysSands) {
            String type = sysSand.getType();
            if (sandTypes.add(type)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", type);
                labelValueMap.put("value", type);
                listSysSandLists.add(labelValueMap);
            }
        }

// 石头类型
        List<SysStone> sysStoneList = sysStoneService.listStones();
        List<Map<String, Object>> listStoneList = new ArrayList<>();
        Set<String> stoneDistributions = new HashSet<>();
*/
/*        for (SysStone sysStone : sysStoneList) {
            String distribution = sysStone.getParticleSizeDistribution();
            if (stoneDistributions.add(distribution)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", distribution);
                labelValueMap.put("value", distribution);
                listStoneList.add(labelValueMap);
            }
        }*//*


// 减水剂
        List<SysWaterReducer> reducers = sysWaterReducerService.listWaterReduce();
        List<Map<String, Object>> listWaterList = new ArrayList<>();
        Set<String> waterReducerModels = new HashSet<>();
        for (SysWaterReducer reducer : reducers) {
            String model = reducer.getModel();
            if (waterReducerModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                listWaterList.add(labelValueMap);
            }
        }

// 粉煤灰
        List<SysFlyash> sysFlyashList = sysFlyashService.listFlyash();
        List<Map<String, Object>> listFlyashList = new ArrayList<>();
        Set<String> flyashGrades = new HashSet<>();
        for (SysFlyash sysFlyash : sysFlyashList) {
            String grade = sysFlyash.getGrade();
            if (flyashGrades.add(grade)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", grade);
                labelValueMap.put("value", grade);
                listFlyashList.add(labelValueMap);
            }
        }

// 高效剂
        List<SysEfficiencyAgent> efficiencyAgents = sysEfficiencyAgent.listefficiencyAgents();
        List<Map<String, Object>> efficiencyAgentList = new ArrayList<>();
        Set<String> efficiencyAgentModels = new HashSet<>();
        for (SysEfficiencyAgent efficiencyAgent : efficiencyAgents) {
            String model = efficiencyAgent.getModel();
            if (efficiencyAgentModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                efficiencyAgentList.add(labelValueMap);
            }
        }

// 水型号
        List<SysWater> listWaterModelList = waterService.list();
        List<Map<String, Object>> waterModelList = new ArrayList<>();
        Set<String> waterModels = new HashSet<>();
        for (SysWater sysWater : listWaterModelList) {
            String model = sysWater.getModel();
            if (waterModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                waterModelList.add(labelValueMap);
            }
        }

// 矿粉型号
        List<SysMineralPowder> listMineralPowderList = sysMineralPowderService.list();
        List<Map<String, Object>> mineralPowderList = new ArrayList<>();
        Set<String> mineralPowderModels = new HashSet<>();
        for (SysMineralPowder sysMineralPowder : listMineralPowderList) {
            String model = sysMineralPowder.getModel();
            if (mineralPowderModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                mineralPowderList.add(labelValueMap);
            }
        }

// 其他型号
        List<SysOtherAdmixtures> listOtherAdmixturesList = sysOtherAdmixturesService.list();
        List<Map<String, Object>> otherAdmixturesList = new ArrayList<>();
        Set<String> otherAdmixtureModels = new HashSet<>();
        for (SysOtherAdmixtures sysOtherAdmixtures : listOtherAdmixturesList) {
            String model = sysOtherAdmixtures.getModel();
            if (otherAdmixtureModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                otherAdmixturesList.add(labelValueMap);
            }
        }

// 膨胀剂型号
        List<SysSwellingagent> listSwellingagentList = sysSwellingagentService.list();
        List<Map<String, Object>> swellingagentList = new ArrayList<>();
        Set<String> swellingagentModels = new HashSet<>();
        for (SysSwellingagent sysSwellingagent : listSwellingagentList) {
            String model = sysSwellingagent.getModel();
            if (swellingagentModels.add(model)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", model);
                labelValueMap.put("value", model);
                swellingagentList.add(labelValueMap);
            }
        }



        // 创建 idsPlus 并填充数据
        Map<String, Object> idListPlus = new HashMap<>();
        idListPlus.put("regionIdList", listRegionList);
        idListPlus.put("cementIdList", cementIdListPlus);
        idListPlus.put("sandIdList", listSysSandLists);
        idListPlus.put("stoneIdList", listStoneList);
        idListPlus.put("waterReducerList", listWaterList);
        idListPlus.put("flyashIdList", listFlyashList);
        idListPlus.put("efficiencyAgentIdList", efficiencyAgentList);
        idListPlus.put("regionList", "");

        idListPlus.put("waterModel", waterModelList);//水
        idListPlus.put("mineralModel",mineralPowderList );//矿粉
        idListPlus.put("otherAdmixturesModel", otherAdmixturesList);//其他型号
        idListPlus.put("swellingagentModel",swellingagentList );//    //其他型号


        Map<String, Object> result = new HashMap<>();
        // result.put("ids", idList);
        result.put("sliderSection", sliderSection);
        result.put("ids", idListPlus);
        return AjaxResult.success(result);


    }
*/
    @PostMapping("exportRawMaterialsExcel1")
    public AjaxResult exportRawMaterialsExcel1(@RequestBody RawMaterialsDTO rawMaterialsDTO) {

        // 获取水泥ID列表
        List<Integer> cementIds = rawMaterialsDTO.getCementIds();
        List<Integer> sandIds = rawMaterialsDTO.getSandIds();
        List<Integer> stoneIds = rawMaterialsDTO.getStoneIds();
        List<Integer> flyashIds = rawMaterialsDTO.getFlyashIds();
        List<Integer> waterReducerIds = rawMaterialsDTO.getWaterReducerIds();


        // 获取水泥数据
        List<SysCement> listCementList = sysCementService.listCementByIds(cementIds);
        List<SysStone> listStoneList = sysStoneService.listStoneByIds(stoneIds);
        List<SysSand> listSandList = sysSandService.listSandByIds(sandIds);
        List<SysFlyash> listFlyasList = sysFlyashService.listFlyashIds(flyashIds);
        List<SysWaterReducer> waterReducerList = sysWaterReducerService.listWaterReduceIds(waterReducerIds);


// 将所有数据放入 Map 中
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("cementList", listCementList);
        resultMap.put("stoneList", listStoneList);
        resultMap.put("sandList", listSandList);
        resultMap.put("flyashList", listFlyasList);
        resultMap.put("waterReducerList", waterReducerList);

        return AjaxResult.success(resultMap);
    }

//    @PostMapping("exportRawMaterialsExcel")
//    public ResponseEntity<byte[]> exportRawMaterialsExcel(@RequestBody RawMaterialsDTO rawMaterialsDTO) throws IOException, UnsupportedEncodingException {
//        // 获取水泥ID列表
//        List<Integer> cementIds = rawMaterialsDTO.getCementIds();
//        List<Integer> sandIds = rawMaterialsDTO.getSandIds();
//        List<Integer> stoneIds = rawMaterialsDTO.getStoneIds();
//        List<Integer> flyashIds = rawMaterialsDTO.getFlyashIds();
//        List<Integer> waterReducerIds = rawMaterialsDTO.getWaterReducerIds();
//
//
//        // 获取水泥数据
//        List<SysCement> listCementList = sysCementService.listCementByIds(cementIds);
//        List<SysStone>  listStoneList  =sysStoneService.listStoneByIds(stoneIds);
//        List<SysSand> listSandList = sysSandService.listSandByIds(sandIds);
//        List<SysFlyash>    listFlyasList      = sysFlyashService.listFlyashIds(flyashIds);
//        List<SysWaterReducer>  waterReducerList    = sysWaterReducerService.listWaterReduceIds(waterReducerIds);
//
//
//
//
//
//        // 创建一个 Excel 工作簿
//        Workbook workbook = new XSSFWorkbook();
//        // 创建一个 Sheet，并命名为 "水泥"
//        Sheet sheet = workbook.createSheet("水泥");
//
//        // 设置表头
//        Row headerRow = sheet.createRow(0);
//        headerRow.createCell(0).setCellValue("水泥ID");
//        headerRow.createCell(1).setCellValue("型号");
//        headerRow.createCell(2).setCellValue("CaO含量 (%)");
//        headerRow.createCell(3).setCellValue("SiO2含量 (%)");
//        headerRow.createCell(4).setCellValue("Al2O3含量 (%)");
//        headerRow.createCell(5).setCellValue("地区");
//        headerRow.createCell(6).setCellValue("地区名称");
//
//        // 填充数据
//        int rowNum = 1;
//        for (SysCement cement : listCementList) {
//            Row row = sheet.createRow(rowNum++);
//            row.createCell(0).setCellValue(cement.getCementId());
//            row.createCell(1).setCellValue(cement.getModel());
//            row.createCell(2).setCellValue(cement.getCaoContent());
//            row.createCell(3).setCellValue(cement.getSio2Content());
//            row.createCell(4).setCellValue(cement.getAl2o3Content());
//            row.createCell(5).setCellValue(cement.getRegionName());
//            row.createCell(6).setCellValue(cement.getRegionNameStr());
//        }
//
//        // 将 Excel 数据写入字节数组输出流
//        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
//        workbook.write(byteArrayOutputStream);
//        byteArrayOutputStream.close();
//
//// 获取 Excel 文件数据
//        byte[] excelData = byteArrayOutputStream.toByteArray();
//
//// 确保字节数组包含有效的 Excel 文件内容
//        String fileName = "水泥数据.xlsx";  // 文件名
//
//
//        // 对文件名进行 URL 编码
//        String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); // 替换 "+" 为 "%20"
//
//        // 设置响应头，并返回 Excel 文件
//// 设置响应头，指示这是一个 Excel 文件并需要下载
//        HttpHeaders headers = new HttpHeaders();
//        headers.add("Content-Disposition", "attachment; filename=水泥数据.xlsx");
//        headers.add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
//
//        return ResponseEntity.ok()
//                .headers(headers)
//                .body(excelData);
//    }


/*
    @GetMapping("/listMechanicalPerformancePullDown")
    public AjaxResult listMechanicalPerformancePullDown() {
        // 获取从数据库中查询到的最大值和最小值
        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();
        // 构建每个字段的最小值和最大值
        Map<String, Object> compressiveStrength3d = new HashMap<>();
        compressiveStrength3d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength3d"));
        compressiveStrength3d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength3d"));

        // 构建每个字段的最小值和最大值
        Map<String, Object> compressiveStrength7d = new HashMap<>();
        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));

        Map<String, Object> compressiveStrength28d = new HashMap<>();
        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));


        // 构建返回结果
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("compressive3d", compressiveStrength3d);
        sliderSection.put("compressive7d", compressiveStrength7d);
        sliderSection.put("compressive28d", compressiveStrength28d);




        // 创建 idsPlus 并填充数据
        Map<String, Object> idListPlus = new HashMap<>();

        Map<String, Object> result = new HashMap<>();
        // result.put("ids", idList);
        result.put("sliderSection", sliderSection);
        result.put("ids", idListPlus);
        return AjaxResult.success(result);
    }

*/


    /**
     * 力学性能下拉框
     *
     * @return
     */
    @GetMapping("/listMechanicalPerformancePullDown")
    public AjaxResult listMechanicalPerformancePullDown() {
        // Step 1: 获取从数据库中查询到的最大值和最小值
        // 调用 service 层的查询方法，获取各个字段的最大值和最小值
        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.queryMechanicalPerformanceMaxMin();

        // Step 2: 构建每个字段的最小值和最大值
        // 3天抗压强度
        Map<String, Object> compressiveStrength3d = new HashMap<>();
        compressiveStrength3d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength3d"));
        compressiveStrength3d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength3d"));

        // 7天抗压强度
        Map<String, Object> compressiveStrength7d = new HashMap<>();
        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));

        // 28天抗压强度
        Map<String, Object> compressiveStrength28d = new HashMap<>();
        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));

        // 用水量
        Map<String, Object> water = new HashMap<>();
        water.put("min", efficiencyMerchantMinAndMax.get("minWater"));
        water.put("max", efficiencyMerchantMinAndMax.get("maxWater"));

        // 水泥用量
        Map<String, Object> cement = new HashMap<>();
        cement.put("min", efficiencyMerchantMinAndMax.get("minCement"));
        cement.put("max", efficiencyMerchantMinAndMax.get("maxCement"));

        // 5-10mm石子用量
        Map<String, Object> stone510 = new HashMap<>();
        stone510.put("min", efficiencyMerchantMinAndMax.get("minStone510"));
        stone510.put("max", efficiencyMerchantMinAndMax.get("maxStone510"));

        // 5-25mm石子用量
        Map<String, Object> stone525 = new HashMap<>();
        stone525.put("min", efficiencyMerchantMinAndMax.get("minStone525"));
        stone525.put("max", efficiencyMerchantMinAndMax.get("maxStone525"));

        // 20-40mm石子用量
        Map<String, Object> stone2040 = new HashMap<>();
        stone2040.put("min", efficiencyMerchantMinAndMax.get("minStone2040"));
        stone2040.put("max", efficiencyMerchantMinAndMax.get("maxStone2040"));

        // 10-20mm石子用量
        Map<String, Object> stone1020 = new HashMap<>();
        stone1020.put("min", efficiencyMerchantMinAndMax.get("minStone1020"));
        stone1020.put("max", efficiencyMerchantMinAndMax.get("maxStone1020"));

        // 10-30mm石子用量
        Map<String, Object> stone1030 = new HashMap<>();
        stone1030.put("min", efficiencyMerchantMinAndMax.get("minStone1030"));
        stone1030.put("max", efficiencyMerchantMinAndMax.get("maxStone1030"));

        // 0-10mm石子用量
        Map<String, Object> stone010 = new HashMap<>();
        stone010.put("min", efficiencyMerchantMinAndMax.get("minStone010"));
        stone010.put("max", efficiencyMerchantMinAndMax.get("maxStone010"));

        // 石子20-31.5mm用量
        Map<String, Object> stoneCoarse2031 = new HashMap<>();
        stoneCoarse2031.put("min", efficiencyMerchantMinAndMax.get("minStoneCoarse2031"));
        stoneCoarse2031.put("max", efficiencyMerchantMinAndMax.get("maxStoneCoarse2031"));

        // 河砂（粗 3.1-3.7mm）用量
        Map<String, Object> sandRiverCoarse3137 = new HashMap<>();
        sandRiverCoarse3137.put("min", efficiencyMerchantMinAndMax.get("minSandRiverCoarse3137"));
        sandRiverCoarse3137.put("max", efficiencyMerchantMinAndMax.get("maxSandRiverCoarse3137"));

        // 河砂（中 2.3-3.0mm）用量
        Map<String, Object> sandRiver2330Med = new HashMap<>();
        sandRiver2330Med.put("min", efficiencyMerchantMinAndMax.get("minSandRiver2330Med"));
        sandRiver2330Med.put("max", efficiencyMerchantMinAndMax.get("maxSandRiver2330Med"));

        // 河砂（细 1.6-2.2mm）用量
        Map<String, Object> sandRiver1622Fine = new HashMap<>();
        sandRiver1622Fine.put("min", efficiencyMerchantMinAndMax.get("minSandRiver1622Fine"));
        sandRiver1622Fine.put("max", efficiencyMerchantMinAndMax.get("maxSandRiver1622Fine"));

        // 机制砂（中 2.3-3.0mm）用量
        Map<String, Object> sandMech2330Med = new HashMap<>();
        sandMech2330Med.put("min", efficiencyMerchantMinAndMax.get("minSandMech2330Med"));
        sandMech2330Med.put("max", efficiencyMerchantMinAndMax.get("maxSandMech2330Med"));

        // 机制砂（粗 3.1-3.7mm）用量
        Map<String, Object> sandMech3137Coarse = new HashMap<>();
        sandMech3137Coarse.put("min", efficiencyMerchantMinAndMax.get("minSandMech3137Coarse"));
        sandMech3137Coarse.put("max", efficiencyMerchantMinAndMax.get("maxSandMech3137Coarse"));

        // 机制砂（细 1.6-2.2mm）用量
        Map<String, Object> sandMech1622Fine = new HashMap<>();
        sandMech1622Fine.put("min", efficiencyMerchantMinAndMax.get("minSandMech1622Fine"));
        sandMech1622Fine.put("max", efficiencyMerchantMinAndMax.get("maxSandMech1622Fine"));

        // 机制砂（0-4.75mm）用量
        Map<String, Object> sandMech0475 = new HashMap<>();
        sandMech0475.put("min", efficiencyMerchantMinAndMax.get("minSandMech0475"));
        sandMech0475.put("max", efficiencyMerchantMinAndMax.get("maxSandMech0475"));

        // 机制砂（0-9mm）用量
        Map<String, Object> sandMech09 = new HashMap<>();
        sandMech09.put("min", efficiencyMerchantMinAndMax.get("minSandMech09"));
        sandMech09.put("max", efficiencyMerchantMinAndMax.get("maxSandMech09"));

        // 石粉用量
        Map<String, Object> stonePowder = new HashMap<>();
        stonePowder.put("min", efficiencyMerchantMinAndMax.get("minStonePowder"));
        stonePowder.put("max", efficiencyMerchantMinAndMax.get("maxStonePowder"));

        // 矿粉用量
        Map<String, Object> mineralPowder = new HashMap<>();
        mineralPowder.put("min", efficiencyMerchantMinAndMax.get("minMineralPowder"));
        mineralPowder.put("max", efficiencyMerchantMinAndMax.get("maxMineralPowder"));

        // 粉煤灰用量
        Map<String, Object> flyAsh = new HashMap<>();
        flyAsh.put("min", efficiencyMerchantMinAndMax.get("minFlyAsh"));
        flyAsh.put("max", efficiencyMerchantMinAndMax.get("maxFlyAsh"));

        // 减水剂用量
        Map<String, Object> waterReducer = new HashMap<>();
        waterReducer.put("min", efficiencyMerchantMinAndMax.get("minWaterReducer"));
        waterReducer.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducer"));

        // 增效剂用量
        Map<String, Object> efficiencyAgent = new HashMap<>();
        efficiencyAgent.put("min", efficiencyMerchantMinAndMax.get("minEfficiencyAgent"));
        efficiencyAgent.put("max", efficiencyMerchantMinAndMax.get("maxEfficiencyAgent"));


//        // 膨胀剂用量
        Map<String, Object> expansionAgentAgent = new HashMap<>();
        expansionAgentAgent.put("min", efficiencyMerchantMinAndMax.get("minExpansionAgentAgenta"));
        expansionAgentAgent.put("max", efficiencyMerchantMinAndMax.get("maxExpansionAgentAgenta"));


        // 膨胀剂用量
//        Map<String, Object> expansionAgentAgent = new HashMap<>();
//        expansionAgentAgent.put("min", 1);
//        expansionAgentAgent.put("max", 10);


        // Step 3: 构建返回结果 - sliderSection
        Map<String, Object> sliderSection = new HashMap<>();
        sliderSection.put("compressive3d", compressiveStrength3d);
        sliderSection.put("compressive7d", compressiveStrength7d);
        sliderSection.put("compressive28d", compressiveStrength28d);
        sliderSection.put("water", water);
        sliderSection.put("cement", cement);
        sliderSection.put("stone510", stone510);
        sliderSection.put("stone525", stone525);
        sliderSection.put("stone2040", stone2040);
        sliderSection.put("stone1020", stone1020);
        sliderSection.put("stone1030", stone1030);
        sliderSection.put("stone010", stone010);
        sliderSection.put("stoneCoarse2031", stoneCoarse2031);
        sliderSection.put("sandRiverCoarse3137", sandRiverCoarse3137);
        sliderSection.put("sandRiver2330Med", sandRiver2330Med);
        sliderSection.put("sandRiver1622Fine", sandRiver1622Fine);
        sliderSection.put("sandMech2330Med", sandMech2330Med);
        sliderSection.put("sandMech3137Coarse", sandMech3137Coarse);
        sliderSection.put("sandMech1622Fine", sandMech1622Fine);
        sliderSection.put("sandMech0475", sandMech0475);
        sliderSection.put("sandMech09", sandMech09);
        sliderSection.put("stonePowder", stonePowder);
        sliderSection.put("mineralPowder", mineralPowder);
        sliderSection.put("flyAsh", flyAsh);
        sliderSection.put("waterReducer", waterReducer);
        sliderSection.put("efficiencyAgent", efficiencyAgent);
        sliderSection.put("expansionAgentAgent", expansionAgentAgent);

        /*-------------------------------------------------------------------------*/
        Map<String, Object> cementMinAndMax = sysCementService.getCementMinAndMax();
        Map<String, Object> stoneMinAndMax = sysStoneService.getStoneMinAndMax();
        Map<String, Object> flyashMinAndMax = sysFlyashService.queryFlyashMaxMin();
        Map<String, Object> sandMinAndMax = sysSandService.querySandMaxMin();
        Map<String, Object> mineralMinAndMax = sysMineralPowderService.queryMineralMaxMin();
        Map<String, Object> otherMinAndMax = sysOtherAdmixturesService.queryMineralMaxMin();
        // 封装水泥表数据
        Map<String, Object> cementCaO = new HashMap<>();
        cementCaO.put("min", cementMinAndMax.get("minCaocontent"));
        cementCaO.put("max", cementMinAndMax.get("maxCaocontent"));

        Map<String, Object> cementSiO2 = new HashMap<>();
        cementSiO2.put("min", cementMinAndMax.get("minSio2content"));
        cementSiO2.put("max", cementMinAndMax.get("maxSio2content"));

        Map<String, Object> cementAl2O3 = new HashMap<>();
        cementAl2O3.put("min", cementMinAndMax.get("minAl2o3content"));
        cementAl2O3.put("max", cementMinAndMax.get("maxAl2o3content"));
        Map<String, Object> cementStrength28d = new HashMap<>();
        cementStrength28d.put("min", cementMinAndMax.get("minCompressiveStrength28d"));
        cementStrength28d.put("max", cementMinAndMax.get("maxCompressiveStrength28d"));

        Map<String, Object> strengthGrade = new HashMap<>();
        strengthGrade.put("min", cementMinAndMax.get("minStrengthGrade"));
        strengthGrade.put("max", cementMinAndMax.get("maxStrengthGrade"));


        //粉煤灰

        Map<String, Object> flyashFineness = new HashMap<>();     // 煤灰 细度(%)
        flyashFineness.put("min", flyashMinAndMax.get("minFineness"));
        flyashFineness.put("max", flyashMinAndMax.get("maxFineness"));


        Map<String, Object> flyashMoistureContent = new HashMap<>();     // 煤灰 含水量(%)
        flyashMoistureContent.put("min", flyashMinAndMax.get("minMoistureContent"));
        flyashMoistureContent.put("max", flyashMinAndMax.get("maxMoistureContent"));


        Map<String, Object> flyashActivityIndex28d = new HashMap<>();     // 煤灰 28天活性指数(%)
        flyashActivityIndex28d.put("min", flyashMinAndMax.get("minActivityIndex28d"));
        flyashActivityIndex28d.put("max", flyashMinAndMax.get("maxActivityIndex28d"));

        // 水泥
        sliderSection.put("cementCaO", cementCaO); //水泥 CaO含量（%）
        sliderSection.put("cementSiO2", cementSiO2); //水泥 SiO2含量（%）
        sliderSection.put("cementAl2O3", cementAl2O3); //水泥 Al2O3含量（%）
        sliderSection.put("cementStrength28d", cementStrength28d); //水泥 28天抗压强度(MPa)
        sliderSection.put("strengthGrade", strengthGrade); //水泥 强度等级


        //煤灰
        sliderSection.put("flyashFineness", flyashFineness); // 煤灰 细度(%)
        sliderSection.put("flyashMoistureContent", flyashMoistureContent);  // 煤灰 含水量(%)
        sliderSection.put("flyashActivityIndex28d", flyashActivityIndex28d); // 煤灰 28天活性指数(%)


        // 其他掺合料
        Map<String, Object> otherFineness = new HashMap<>();     // 其他掺合料 细度
        otherFineness.put("min", otherMinAndMax.get("minFineness"));
        otherFineness.put("max", otherMinAndMax.get("maxFineness"));


        Map<String, Object> otherMoistureContent = new HashMap<>();     // 其他掺合料 含水量(%)
        otherMoistureContent.put("min", otherMinAndMax.get("minMoistureContent"));
        otherMoistureContent.put("max", otherMinAndMax.get("maxMoistureContent"));

        Map<String, Object> otherActivityIndex28d = new HashMap<>();     // 其他掺合料 28天活性指数(%)
        otherActivityIndex28d.put("min", otherMinAndMax.get("minActivityIndex28d"));
        otherActivityIndex28d.put("max", otherMinAndMax.get("maxActivityIndex28d"));


        //矿粉
        Map<String, Object> mineralFineness = new HashMap<>();     // 矿粉 细度(%)
        mineralFineness.put("min", mineralMinAndMax.get("minFineness"));
        mineralFineness.put("max", mineralMinAndMax.get("maxFineness"));


        Map<String, Object> mineralMoistureContent = new HashMap<>();     // 矿粉 含水量(%)
        mineralMoistureContent.put("min", mineralMinAndMax.get("minMoistureContent"));
        mineralMoistureContent.put("max", mineralMinAndMax.get("maxMoistureContent"));


        Map<String, Object> mineralActivityIndex28d = new HashMap<>();     // 矿粉 28天活性指数(%)
        mineralActivityIndex28d.put("min", mineralMinAndMax.get("minActivityIndex28d"));
        mineralActivityIndex28d.put("max", mineralMinAndMax.get("maxActivityIndex28d"));

        //矿粉
        sliderSection.put("mineralFineness", mineralFineness);  // 矿粉 细度(%)
        sliderSection.put("mineralMoistureContent", mineralMoistureContent); // 矿粉 含水量(%)
        sliderSection.put("mineralActivityIndex28d", mineralActivityIndex28d);// 矿粉 28天活性指数(%)


        //其他参合料(石粉)
        sliderSection.put("otherFineness", otherFineness);// 石粉 细度
        sliderSection.put("otherMoistureContent", otherMoistureContent);// 石粉 含水量(%)
        sliderSection.put("otherActivityIndex28d", otherActivityIndex28d);// 石粉 28天活性指数(%)


        //获取减水剂
        Map<String, Object> waterReducerMinAndMax = sysWaterReducerService.getwaterReducerAndMax();


        // 含固量
        Map<String, Object> solidContent = new HashMap<>();
        solidContent.put("min", waterReducerMinAndMax.get("minSolidContent"));
        solidContent.put("max", waterReducerMinAndMax.get("maxSolidContent"));

        //减水率%
        Map<String, Object> reducingRate = new HashMap<>();
        reducingRate.put("min", waterReducerMinAndMax.get("minReducingRate"));
        reducingRate.put("max", waterReducerMinAndMax.get("maxReducingRate"));

        //水泥净浆流动度(mm)
        Map<String, Object> reducingCementPasteFlow = new HashMap<>();
        reducingCementPasteFlow.put("min", waterReducerMinAndMax.get("minCementPasteFlow"));
        reducingCementPasteFlow.put("max", waterReducerMinAndMax.get("maxCementPasteFlow"));
        //减水剂
        sliderSection.put("solidContent", solidContent); // 减水剂含固量
        sliderSection.put("reducingRate", reducingRate); //减水剂减水率%
        sliderSection.put("reducingCementPasteFlow", reducingCementPasteFlow);//减水剂水泥净浆流动度



        /*------------------------------------------------------------------------------------------------------*/


        // Step 4: 创建 idsPlus 并填充数据
        Map<String, Object> idListPlus = new HashMap<>();

        /*-------------------------------New--------------------------------------*/

        //获取水泥表 型号
        List<SysCement> listCement = sysCementService.list();
        // 使用 Set 保证去重
        Set<String> modelCementSet = listCement.stream()
                .map(SysCement::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> cementModellistVOList = modelCementSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //粉煤灰 型号
        List<SysFlyash> listFlyash = sysFlyashService.list();
        // 使用 Set 保证去重
        Set<String> flyashGradelSet = listFlyash.stream()
                .map(SysFlyash::getGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> flyashGradellistVOList = flyashGradelSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //粉煤灰 等级
        Set<String> flyashFactoryGrade = listFlyash.stream()
                .map(SysFlyash::getFactoryGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> flyashFactoryGradelistVOList = flyashFactoryGrade.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //矿粉型号
        List<SysMineralPowder> listMineral = sysMineralPowderService.list();
        Set<String> mineralModel = listMineral.stream()
                .map(SysMineralPowder::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重

        List<SandFinenessVO> mineralModellistVOList = mineralModel.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //矿粉矿渣等级
        Set<String> lagGrade = listMineral.stream()
                .map(SysMineralPowder::getSlagGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> minerallagGradelistVOList = lagGrade.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //石粉 型号
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();

        // 使用 Set 保证去重
        Set<String> OtherAdmixturesSet = listOtherAdmixtures.stream()
                .map(SysOtherAdmixtures::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> otherModellistVOList = OtherAdmixturesSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());
        /*-------------------------------New--------------------------------------*/

        //水泥
        idListPlus.put("cementModel", cementModellistVOList); // 水泥表 类型
        //粉煤灰
        idListPlus.put("pfaTypeOptions", flyashGradellistVOList); //粉煤灰类型
        idListPlus.put("pfaFineOptions", flyashFactoryGradelistVOList); //粉煤灰等级
        //矿粉
        idListPlus.put("mineralModel", mineralModellistVOList); //矿粉型号
        idListPlus.put("minerallagGrade", minerallagGradelistVOList);//矿粉 矿渣等级

        // 石粉
        idListPlus.put("otherAdmixturesModel", otherModellistVOList); //// 其他掺合料型号



        /*------------------------------------------------------------*/

        //减水剂型号
        List<SysWaterReducer> listWaterReducer = sysWaterReducerService.list();
        Set<String> waterReducerSet = listWaterReducer.stream()
                .map(SysWaterReducer::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> wateModellistVOList = waterReducerSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //减水剂商家
        Set<String> waterSourceName = listWaterReducer.stream()
                .map(SysWaterReducer::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> waterSourceNameVOList = waterSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());
        //增效剂型号
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
        Set<String> efficiencyAgentSet = listEfficiencyAgent.stream()
                .map(SysEfficiencyAgent::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> agentModel = efficiencyAgentSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //增效剂商家
        Set<String> agentSourceName = listEfficiencyAgent.stream()
                .map(SysEfficiencyAgent::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> agentSourceNameVOList = agentSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //膨胀剂型号
        List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
        Set<String> swellingagentSet = listSwellingagent.stream()
                .map(SysSwellingagent::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> swellingagentModel = swellingagentSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //膨胀剂商家
        Set<String> sysSwellingagentSourceName = listSwellingagent.stream()
                .map(SysSwellingagent::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> sysSwellingagentSourceNameVOList = sysSwellingagentSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //减水剂
        idListPlus.put("waterReducerModel", wateModellistVOList);//减水剂型号
        idListPlus.put("waterSourceName", waterSourceNameVOList); //减水剂商家

        //增效剂
        idListPlus.put("agentModel", agentModel);//增效剂型号
        idListPlus.put("agentSourceName", agentSourceNameVOList); //增效剂商家

        //膨胀剂
        idListPlus.put("swellingagentModel", swellingagentModel);//膨胀剂型号
        idListPlus.put("swellingagentSource", sysSwellingagentSourceNameVOList); //膨胀剂商家


        List<Region> listRegionList = regionService.list();

        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        Set<String> regionFullName = new HashSet<>();
        for (Region region : listRegionList) {
            String fullName = region.getFullName();
            if (regionFullName.add(fullName)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", fullName);
                labelValueMap.put("value", fullName);
                listSysSandLists.add(labelValueMap);
            }

        }


        LambdaQueryWrapper<SysMechanicalPerformance> wrapper = new LambdaQueryWrapper<>();
        wrapper.select(SysMechanicalPerformance::getStrengthGrade);
        List<SysMechanicalPerformance> listMechanicalPerformance = sysMechanicalPerformanceService.list(wrapper);
        List<Map<String, Object>> listStrengthGrade = new ArrayList<>();
        Set<String> listSetStrengthGrade = new HashSet<>();
        for (SysMechanicalPerformance region : listMechanicalPerformance) {

            String fullName = region.getStrengthGrade();

            if (listSetStrengthGrade.add(fullName)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", fullName);
                labelValueMap.put("value", fullName);
                listStrengthGrade.add(labelValueMap);
            }

        }


        idListPlus.put("regionIdList", listSysSandLists);
        idListPlus.put("listStrengthGrade", listStrengthGrade);

        // Step 5: 构建最终的结果对象
        Map<String, Object> result = new HashMap<>();
        result.put("sliderSection", sliderSection);
        result.put("ids", idListPlus);

        // Step 6: 返回成功响应，封装为 AjaxResult
        return AjaxResult.success(result);
    }


    /**
     * 坍落度力学性能
     */

    @GetMapping("/listSysSlumpPullDown")
    public AjaxResult listSysSlumpPullDown() {
        // Step 1: 获取从数据库中查询到的最大值和最小值
        // 调用 service 层的查询方法，获取各个字段的最大值和最小值
        Map<String, Object> efficiencyMerchantMinAndMax = sysEfficiencyMerchantNameService.listSysSlumpPullDown();


        //坍落度
        Map<String, Object> compresSlump = new HashMap<>();
        compresSlump.put("min", efficiencyMerchantMinAndMax.get("minSlump"));
        compresSlump.put("max", efficiencyMerchantMinAndMax.get("maxSlump"));


        // Step 2: 构建每个字段的最小值和最大值
        // 3天抗压强度
//        Map<String, Object> compressiveStrength3d = new HashMap<>();
//        compressiveStrength3d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength3d"));
//        compressiveStrength3d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength3d"));
//
//        // 7天抗压强度
//        Map<String, Object> compressiveStrength7d = new HashMap<>();
//        compressiveStrength7d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength7d"));
//        compressiveStrength7d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength7d"));
//
//        // 28天抗压强度
//        Map<String, Object> compressiveStrength28d = new HashMap<>();
//        compressiveStrength28d.put("min", efficiencyMerchantMinAndMax.get("minCompressiveStrength28d"));
//        compressiveStrength28d.put("max", efficiencyMerchantMinAndMax.get("maxCompressiveStrength28d"));

        // 用水量
        Map<String, Object> water = new HashMap<>();
        water.put("min", efficiencyMerchantMinAndMax.get("minWater"));
        water.put("max", efficiencyMerchantMinAndMax.get("maxWater"));

        // 水泥用量
        Map<String, Object> cement = new HashMap<>();
        cement.put("min", efficiencyMerchantMinAndMax.get("minCement"));
        cement.put("max", efficiencyMerchantMinAndMax.get("maxCement"));

        // 5-10mm石子用量
        Map<String, Object> stone510 = new HashMap<>();
        stone510.put("min", efficiencyMerchantMinAndMax.get("minStone510"));
        stone510.put("max", efficiencyMerchantMinAndMax.get("maxStone510"));

        // 5-25mm石子用量
        Map<String, Object> stone525 = new HashMap<>();
        stone525.put("min", efficiencyMerchantMinAndMax.get("minStone525"));
        stone525.put("max", efficiencyMerchantMinAndMax.get("maxStone525"));

        // 20-40mm石子用量
        Map<String, Object> stone2040 = new HashMap<>();
        stone2040.put("min", efficiencyMerchantMinAndMax.get("minStone2040"));
        stone2040.put("max", efficiencyMerchantMinAndMax.get("maxStone2040"));

        // 10-20mm石子用量
        Map<String, Object> stone1020 = new HashMap<>();
        stone1020.put("min", efficiencyMerchantMinAndMax.get("minStone1020"));
        stone1020.put("max", efficiencyMerchantMinAndMax.get("maxStone1020"));

        // 10-30mm石子用量
        Map<String, Object> stone1030 = new HashMap<>();
        stone1030.put("min", efficiencyMerchantMinAndMax.get("minStone1030"));
        stone1030.put("max", efficiencyMerchantMinAndMax.get("maxStone1030"));

        // 0-10mm石子用量
        Map<String, Object> stone010 = new HashMap<>();
        stone010.put("min", efficiencyMerchantMinAndMax.get("minStone010"));
        stone010.put("max", efficiencyMerchantMinAndMax.get("maxStone010"));

        // 石子20-31.5mm用量
        Map<String, Object> stoneCoarse2031 = new HashMap<>();
        stoneCoarse2031.put("min", efficiencyMerchantMinAndMax.get("minStoneCoarse2031"));
        stoneCoarse2031.put("max", efficiencyMerchantMinAndMax.get("maxStoneCoarse2031"));

        // 河砂（粗 3.1-3.7mm）用量
        Map<String, Object> sandRiverCoarse3137 = new HashMap<>();
        sandRiverCoarse3137.put("min", efficiencyMerchantMinAndMax.get("minSandRiverCoarse3137"));
        sandRiverCoarse3137.put("max", efficiencyMerchantMinAndMax.get("maxSandRiverCoarse3137"));

        // 河砂（中 2.3-3.0mm）用量
        Map<String, Object> sandRiver2330Med = new HashMap<>();
        sandRiver2330Med.put("min", efficiencyMerchantMinAndMax.get("minSandRiver2330Med"));
        sandRiver2330Med.put("max", efficiencyMerchantMinAndMax.get("maxSandRiver2330Med"));

        // 河砂（细 1.6-2.2mm）用量
        Map<String, Object> sandRiver1622Fine = new HashMap<>();
        sandRiver1622Fine.put("min", efficiencyMerchantMinAndMax.get("minSandRiver1622Fine"));
        sandRiver1622Fine.put("max", efficiencyMerchantMinAndMax.get("maxSandRiver1622Fine"));

        // 机制砂（中 2.3-3.0mm）用量
        Map<String, Object> sandMech2330Med = new HashMap<>();
        sandMech2330Med.put("min", efficiencyMerchantMinAndMax.get("minSandMech2330Med"));
        sandMech2330Med.put("max", efficiencyMerchantMinAndMax.get("maxSandMech2330Med"));

        // 机制砂（粗 3.1-3.7mm）用量
        Map<String, Object> sandMech3137Coarse = new HashMap<>();
        sandMech3137Coarse.put("min", efficiencyMerchantMinAndMax.get("minSandMech3137Coarse"));
        sandMech3137Coarse.put("max", efficiencyMerchantMinAndMax.get("maxSandMech3137Coarse"));

        // 机制砂（细 1.6-2.2mm）用量
        Map<String, Object> sandMech1622Fine = new HashMap<>();
        sandMech1622Fine.put("min", efficiencyMerchantMinAndMax.get("minSandMech1622Fine"));
        sandMech1622Fine.put("max", efficiencyMerchantMinAndMax.get("maxSandMech1622Fine"));

        // 机制砂（0-4.75mm）用量
        Map<String, Object> sandMech0475 = new HashMap<>();
        sandMech0475.put("min", efficiencyMerchantMinAndMax.get("minSandMech0475"));
        sandMech0475.put("max", efficiencyMerchantMinAndMax.get("maxSandMech0475"));

        // 机制砂（0-9mm）用量
        Map<String, Object> sandMech09 = new HashMap<>();
        sandMech09.put("min", efficiencyMerchantMinAndMax.get("minSandMech09"));
        sandMech09.put("max", efficiencyMerchantMinAndMax.get("maxSandMech09"));

        // 石粉用量
        Map<String, Object> stonePowder = new HashMap<>();
        stonePowder.put("min", efficiencyMerchantMinAndMax.get("minStonePowder"));
        stonePowder.put("max", efficiencyMerchantMinAndMax.get("maxStonePowder"));

        // 矿粉用量
        Map<String, Object> mineralPowder = new HashMap<>();
        mineralPowder.put("min", efficiencyMerchantMinAndMax.get("minMineralPowder"));
        mineralPowder.put("max", efficiencyMerchantMinAndMax.get("maxMineralPowder"));

        // 粉煤灰用量
        Map<String, Object> flyAsh = new HashMap<>();
        flyAsh.put("min", efficiencyMerchantMinAndMax.get("minFlyAsh"));
        flyAsh.put("max", efficiencyMerchantMinAndMax.get("maxFlyAsh"));

        // 减水剂用量
        Map<String, Object> waterReducer = new HashMap<>();
        waterReducer.put("min", efficiencyMerchantMinAndMax.get("minWaterReducer"));
        waterReducer.put("max", efficiencyMerchantMinAndMax.get("maxWaterReducer"));

        // 增效剂用量
        Map<String, Object> efficiencyAgent = new HashMap<>();
        efficiencyAgent.put("min", efficiencyMerchantMinAndMax.get("minEfficiencyAgent"));
        efficiencyAgent.put("max", efficiencyMerchantMinAndMax.get("maxEfficiencyAgent"));


//        // 膨胀剂用量
        Map<String, Object> expansionAgentAgent = new HashMap<>();
        expansionAgentAgent.put("min", efficiencyMerchantMinAndMax.get("minExpansionAgentAgenta"));
        expansionAgentAgent.put("max", efficiencyMerchantMinAndMax.get("maxExpansionAgentAgenta"));


        // 膨胀剂用量
//        Map<String, Object> expansionAgentAgent = new HashMap<>();
//        expansionAgentAgent.put("min", 1);
//        expansionAgentAgent.put("max", 10);


        // Step 3: 构建返回结果 - sliderSection
        Map<String, Object> sliderSection = new HashMap<>();

        sliderSection.put("compresSlump", compresSlump);

//        sliderSection.put("compressive3d", compressiveStrength3d);
//        sliderSection.put("compressive7d", compressiveStrength7d);
//        sliderSection.put("compressive28d", compressiveStrength28d);
        sliderSection.put("water", water);
        sliderSection.put("cement", cement);
        sliderSection.put("stone510", stone510);
        sliderSection.put("stone525", stone525);
        sliderSection.put("stone2040", stone2040);
        sliderSection.put("stone1020", stone1020);
        sliderSection.put("stone1030", stone1030);
        sliderSection.put("stone010", stone010);
        sliderSection.put("stoneCoarse2031", stoneCoarse2031);
        sliderSection.put("sandRiverCoarse3137", sandRiverCoarse3137);
        sliderSection.put("sandRiver2330Med", sandRiver2330Med);
        sliderSection.put("sandRiver1622Fine", sandRiver1622Fine);
        sliderSection.put("sandMech2330Med", sandMech2330Med);
        sliderSection.put("sandMech3137Coarse", sandMech3137Coarse);
        sliderSection.put("sandMech1622Fine", sandMech1622Fine);
        sliderSection.put("sandMech0475", sandMech0475);
        sliderSection.put("sandMech09", sandMech09);
        sliderSection.put("stonePowder", stonePowder);
        sliderSection.put("mineralPowder", mineralPowder);
        sliderSection.put("flyAsh", flyAsh);
        sliderSection.put("waterReducer", waterReducer);
        sliderSection.put("efficiencyAgent", efficiencyAgent);
        sliderSection.put("expansionAgentAgent", expansionAgentAgent);

        /*-------------------------------------------------------------------------*/
        Map<String, Object> cementMinAndMax = sysCementService.getCementMinAndMax();
        Map<String, Object> stoneMinAndMax = sysStoneService.getStoneMinAndMax();
        Map<String, Object> flyashMinAndMax = sysFlyashService.queryFlyashMaxMin();
        Map<String, Object> sandMinAndMax = sysSandService.querySandMaxMin();
        Map<String, Object> mineralMinAndMax = sysMineralPowderService.queryMineralMaxMin();
        Map<String, Object> otherMinAndMax = sysOtherAdmixturesService.queryMineralMaxMin();
        // 封装水泥表数据
        Map<String, Object> cementCaO = new HashMap<>();
        cementCaO.put("min", cementMinAndMax.get("minCaocontent"));
        cementCaO.put("max", cementMinAndMax.get("maxCaocontent"));

        Map<String, Object> cementSiO2 = new HashMap<>();
        cementSiO2.put("min", cementMinAndMax.get("minSio2content"));
        cementSiO2.put("max", cementMinAndMax.get("maxSio2content"));

        Map<String, Object> cementAl2O3 = new HashMap<>();
        cementAl2O3.put("min", cementMinAndMax.get("minAl2o3content"));
        cementAl2O3.put("max", cementMinAndMax.get("maxAl2o3content"));
        Map<String, Object> cementStrength28d = new HashMap<>();
        cementStrength28d.put("min", cementMinAndMax.get("minCompressiveStrength28d"));
        cementStrength28d.put("max", cementMinAndMax.get("maxCompressiveStrength28d"));

        Map<String, Object> strengthGrade = new HashMap<>();
        strengthGrade.put("min", cementMinAndMax.get("minStrengthGrade"));
        strengthGrade.put("max", cementMinAndMax.get("maxStrengthGrade"));


        //粉煤灰

        Map<String, Object> flyashFineness = new HashMap<>();     // 煤灰 细度(%)
        flyashFineness.put("min", flyashMinAndMax.get("minFineness"));
        flyashFineness.put("max", flyashMinAndMax.get("maxFineness"));


        Map<String, Object> flyashMoistureContent = new HashMap<>();     // 煤灰 含水量(%)
        flyashMoistureContent.put("min", flyashMinAndMax.get("minMoistureContent"));
        flyashMoistureContent.put("max", flyashMinAndMax.get("maxMoistureContent"));


        Map<String, Object> flyashActivityIndex28d = new HashMap<>();     // 煤灰 28天活性指数(%)
        flyashActivityIndex28d.put("min", flyashMinAndMax.get("minActivityIndex28d"));
        flyashActivityIndex28d.put("max", flyashMinAndMax.get("maxActivityIndex28d"));

        // 水泥
        sliderSection.put("cementCaO", cementCaO); //水泥 CaO含量（%）
        sliderSection.put("cementSiO2", cementSiO2); //水泥 SiO2含量（%）
        sliderSection.put("cementAl2O3", cementAl2O3); //水泥 Al2O3含量（%）
        sliderSection.put("cementStrength28d", cementStrength28d); //水泥 28天抗压强度(MPa)
        sliderSection.put("strengthGrade", strengthGrade); //水泥 强度等级


        //煤灰
        sliderSection.put("flyashFineness", flyashFineness); // 煤灰 细度(%)
        sliderSection.put("flyashMoistureContent", flyashMoistureContent);  // 煤灰 含水量(%)
        sliderSection.put("flyashActivityIndex28d", flyashActivityIndex28d); // 煤灰 28天活性指数(%)


        // 其他掺合料
        Map<String, Object> otherFineness = new HashMap<>();     // 其他掺合料 细度
        otherFineness.put("min", otherMinAndMax.get("minFineness"));
        otherFineness.put("max", otherMinAndMax.get("maxFineness"));


        Map<String, Object> otherMoistureContent = new HashMap<>();     // 其他掺合料 含水量(%)
        otherMoistureContent.put("min", otherMinAndMax.get("minMoistureContent"));
        otherMoistureContent.put("max", otherMinAndMax.get("maxMoistureContent"));

        Map<String, Object> otherActivityIndex28d = new HashMap<>();     // 其他掺合料 28天活性指数(%)
        otherActivityIndex28d.put("min", otherMinAndMax.get("minActivityIndex28d"));
        otherActivityIndex28d.put("max", otherMinAndMax.get("maxActivityIndex28d"));


        //矿粉
        Map<String, Object> mineralFineness = new HashMap<>();     // 矿粉 细度(%)
        mineralFineness.put("min", mineralMinAndMax.get("minFineness"));
        mineralFineness.put("max", mineralMinAndMax.get("maxFineness"));


        Map<String, Object> mineralMoistureContent = new HashMap<>();     // 矿粉 含水量(%)
        mineralMoistureContent.put("min", mineralMinAndMax.get("minMoistureContent"));
        mineralMoistureContent.put("max", mineralMinAndMax.get("maxMoistureContent"));


        Map<String, Object> mineralActivityIndex28d = new HashMap<>();     // 矿粉 28天活性指数(%)
        mineralActivityIndex28d.put("min", mineralMinAndMax.get("minActivityIndex28d"));
        mineralActivityIndex28d.put("max", mineralMinAndMax.get("maxActivityIndex28d"));

        //矿粉
        sliderSection.put("mineralFineness", mineralFineness);  // 矿粉 细度(%)
        sliderSection.put("mineralMoistureContent", mineralMoistureContent); // 矿粉 含水量(%)
        sliderSection.put("mineralActivityIndex28d", mineralActivityIndex28d);// 矿粉 28天活性指数(%)


        //其他参合料(石粉)
        sliderSection.put("otherFineness", otherFineness);// 石粉 细度
        sliderSection.put("otherMoistureContent", otherMoistureContent);// 石粉 含水量(%)
        sliderSection.put("otherActivityIndex28d", otherActivityIndex28d);// 石粉 28天活性指数(%)


        //获取减水剂
        Map<String, Object> waterReducerMinAndMax = sysWaterReducerService.getwaterReducerAndMax();


        // 含固量
        Map<String, Object> solidContent = new HashMap<>();
        solidContent.put("min", waterReducerMinAndMax.get("minSolidContent"));
        solidContent.put("max", waterReducerMinAndMax.get("maxSolidContent"));

        //减水率%
        Map<String, Object> reducingRate = new HashMap<>();
        reducingRate.put("min", waterReducerMinAndMax.get("minReducingRate"));
        reducingRate.put("max", waterReducerMinAndMax.get("maxReducingRate"));

        //水泥净浆流动度(mm)
        Map<String, Object> reducingCementPasteFlow = new HashMap<>();
        reducingCementPasteFlow.put("min", waterReducerMinAndMax.get("minCementPasteFlow"));
        reducingCementPasteFlow.put("max", waterReducerMinAndMax.get("maxCementPasteFlow"));
        //减水剂
        sliderSection.put("solidContent", solidContent); // 减水剂含固量
        sliderSection.put("reducingRate", reducingRate); //减水剂减水率%
        sliderSection.put("reducingCementPasteFlow", reducingCementPasteFlow);//减水剂水泥净浆流动度



        /*------------------------------------------------------------------------------------------------------*/


        // Step 4: 创建 idsPlus 并填充数据
        Map<String, Object> idListPlus = new HashMap<>();

        /*-------------------------------New--------------------------------------*/

        //获取水泥表 型号
        List<SysCement> listCement = sysCementService.list();
        // 使用 Set 保证去重
        Set<String> modelCementSet = listCement.stream()
                .map(SysCement::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> cementModellistVOList = modelCementSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //粉煤灰 型号
        List<SysFlyash> listFlyash = sysFlyashService.list();
        // 使用 Set 保证去重
        Set<String> flyashGradelSet = listFlyash.stream()
                .map(SysFlyash::getGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> flyashGradellistVOList = flyashGradelSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //粉煤灰 等级
        Set<String> flyashFactoryGrade = listFlyash.stream()
                .map(SysFlyash::getFactoryGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> flyashFactoryGradelistVOList = flyashFactoryGrade.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //矿粉型号
        List<SysMineralPowder> listMineral = sysMineralPowderService.list();
        Set<String> mineralModel = listMineral.stream()
                .map(SysMineralPowder::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重

        List<SandFinenessVO> mineralModellistVOList = mineralModel.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //矿粉矿渣等级
        Set<String> lagGrade = listMineral.stream()
                .map(SysMineralPowder::getSlagGrade) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> minerallagGradelistVOList = lagGrade.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //石粉 型号
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();

        // 使用 Set 保证去重
        Set<String> OtherAdmixturesSet = listOtherAdmixtures.stream()
                .map(SysOtherAdmixtures::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> otherModellistVOList = OtherAdmixturesSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());
        /*-------------------------------New--------------------------------------*/

        //水泥
        idListPlus.put("cementModel", cementModellistVOList); // 水泥表 类型
        //粉煤灰
        idListPlus.put("pfaTypeOptions", flyashGradellistVOList); //粉煤灰类型
        idListPlus.put("pfaFineOptions", flyashFactoryGradelistVOList); //粉煤灰等级
        //矿粉
        idListPlus.put("mineralModel", mineralModellistVOList); //矿粉型号
        idListPlus.put("minerallagGrade", minerallagGradelistVOList);//矿粉 矿渣等级

        // 石粉
        idListPlus.put("otherAdmixturesModel", otherModellistVOList); //// 其他掺合料型号



        /*------------------------------------------------------------*/

        //减水剂型号
        List<SysWaterReducer> listWaterReducer = sysWaterReducerService.list();
        Set<String> waterReducerSet = listWaterReducer.stream()
                .map(SysWaterReducer::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> wateModellistVOList = waterReducerSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //减水剂商家
        Set<String> waterSourceName = listWaterReducer.stream()
                .map(SysWaterReducer::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> waterSourceNameVOList = waterSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());
        //增效剂型号
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
        Set<String> efficiencyAgentSet = listEfficiencyAgent.stream()
                .map(SysEfficiencyAgent::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> agentModel = efficiencyAgentSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //增效剂商家
        Set<String> agentSourceName = listEfficiencyAgent.stream()
                .map(SysEfficiencyAgent::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> agentSourceNameVOList = agentSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //膨胀剂型号
        List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
        Set<String> swellingagentSet = listSwellingagent.stream()
                .map(SysSwellingagent::getModel) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> swellingagentModel = swellingagentSet.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());


        //膨胀剂商家
        Set<String> sysSwellingagentSourceName = listSwellingagent.stream()
                .map(SysSwellingagent::getSourceName) // 提取出 model 字段
                .collect(Collectors.toSet()); // 使用 Set 去重
        List<SandFinenessVO> sysSwellingagentSourceNameVOList = sysSwellingagentSourceName.stream()
                .map(model -> {
                    SandFinenessVO vo = new SandFinenessVO();
                    vo.setValue(model);
                    vo.setLabel(model);
                    return vo;
                })
                .collect(Collectors.toList());

        //减水剂
        idListPlus.put("waterReducerModel", wateModellistVOList);//减水剂型号
        idListPlus.put("waterSourceName", waterSourceNameVOList); //减水剂商家

        //增效剂
        idListPlus.put("agentModel", agentModel);//增效剂型号
        idListPlus.put("agentSourceName", agentSourceNameVOList); //增效剂商家

        //膨胀剂
        idListPlus.put("swellingagentModel", swellingagentModel);//膨胀剂型号
        idListPlus.put("swellingagentSource", sysSwellingagentSourceNameVOList); //膨胀剂商家


        List<Region> listRegionList = regionService.list();

        List<Map<String, Object>> listSysSandLists = new ArrayList<>();
        Set<String> regionFullName = new HashSet<>();
        for (Region region : listRegionList) {
            String fullName = region.getFullName();
            if (regionFullName.add(fullName)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", fullName);
                labelValueMap.put("value", fullName);
                listSysSandLists.add(labelValueMap);
            }

        }


        LambdaQueryWrapper<SysMechanicalPerformance> wrapper = new LambdaQueryWrapper<>();
        wrapper.select(SysMechanicalPerformance::getStrengthGrade);
        List<SysMechanicalPerformance> listMechanicalPerformance = sysMechanicalPerformanceService.list(wrapper);
        List<Map<String, Object>> listStrengthGrade = new ArrayList<>();
        Set<String> listSetStrengthGrade = new HashSet<>();
        for (SysMechanicalPerformance region : listMechanicalPerformance) {

            String fullName = region.getStrengthGrade();

            if (listSetStrengthGrade.add(fullName)) { // 去重
                Map<String, Object> labelValueMap = new HashMap<>();
                labelValueMap.put("label", fullName);
                labelValueMap.put("value", fullName);
                listStrengthGrade.add(labelValueMap);
            }

        }


        idListPlus.put("regionIdList", listSysSandLists);
        idListPlus.put("listStrengthGrade", listStrengthGrade);

        // Step 5: 构建最终的结果对象
        Map<String, Object> result = new HashMap<>();
        result.put("sliderSection", sliderSection);
        result.put("ids", idListPlus);

        // Step 6: 返回成功响应，封装为 AjaxResult
        return AjaxResult.success(result);
    }

    /**
     * 查询地区的数量
     *
     * @return
     */
    @GetMapping("querySysCement")
    public AjaxResult querySysCement() {

        // 查询所有地区
        List<Region> regionList = regionService.list();

        // 构建市级地区Map (level=2)
        Map<Integer, Region> cityMap = regionList.stream()
                .filter(r -> r.getLevel() == 2)
                .collect(Collectors.toMap(Region::getId, r -> r));

        // 构建区县ID(level=3) -> 所属市ID(level=2) 映射
        Map<Integer, Integer> countyToCityMap = new HashMap<>();
        for (Region region : regionList) {
            if (region.getLevel() == 3 && region.getParentId() != null) {
                countyToCityMap.put(region.getId(), region.getParentId());
            } else if (region.getLevel() == 2) {
                countyToCityMap.put(region.getId(), region.getId());  // 市ID映射到自己
            }
        }

        // 查询所有原料数据
        List<SysCement> listCement = sysCementService.list();
        List<SysStone> listStone = sysStoneService.list();
        List<SysSand> listSand = sysSandService.list();
        List<SysFlyash> listFlyash = sysFlyashService.list();
        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();

        // 汇总统计（key是市ID）
        Map<Integer, Integer> totalRegionCountMap = new HashMap<>();
        mergeRegionCount(totalRegionCountMap, listCement, countyToCityMap);
        mergeRegionCount(totalRegionCountMap, listStone, countyToCityMap);
        mergeRegionCount(totalRegionCountMap, listSand, countyToCityMap);
        mergeRegionCount(totalRegionCountMap, listFlyash, countyToCityMap);
        mergeRegionCount(totalRegionCountMap, listMineralPowder, countyToCityMap);
        mergeRegionCount(totalRegionCountMap, listOtherAdmixtures, countyToCityMap);

        // 构建结果，只返回市级地区数据
        List<Map<String, Object>> result = new ArrayList<>();
        for (Map.Entry<Integer, Integer> entry : totalRegionCountMap.entrySet()) {
            Integer cityId = entry.getKey();
            Integer count = entry.getValue();
            Region cityRegion = cityMap.get(cityId);
            if (cityRegion != null) {  // 只返回市级地区
                Map<String, Object> item = new HashMap<>();
                item.put("regionId", cityId);
                item.put("regionName", cityRegion.getName());
                item.put("count", count);
                result.add(item);
            }
        }

        return AjaxResult.success(result);
    }

    // 泛型统计方法：将每个物料列表的统计合并到总Map中，key是市ID
    private <T> void mergeRegionCount(Map<Integer, Integer> totalMap, List<T> list, Map<Integer, Integer> countyToCityMap) {
        for (T item : list) {
            try {
                Field regionField = item.getClass().getDeclaredField("regionName");  // 你的实体类中字段名，确认是regionName
                regionField.setAccessible(true);
                Integer regionId = (Integer) regionField.get(item);
                if (regionId != null) {
                    Integer cityId = countyToCityMap.get(regionId);
                    if (cityId != null) {
                        totalMap.put(cityId, totalMap.getOrDefault(cityId, 0) + 1);
                    }
                }
            } catch (NoSuchFieldException | IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }


    /**
     * 查询水泥的详细信息
     *
     * @return
     */

    @PostMapping("queryCement")
    public AjaxResult queryCement(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        // 如果 cityId 不为空，获取该市的所有下级区县 ID (level=3)
        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());
        }

        // 构造基础查询条件
        QueryWrapper<SysCement> baseWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            baseWrapper.in("region_name", districtIds);
        }

        // 查询所有符合条件的水泥数据
        List<SysCement> filteredCements = sysCementService.list(baseWrapper);

        // 构造 contents 数组，放入CaO, SiO2, Al2O3含量
        List<Map<String, Object>> contents = new ArrayList<>();
        for (SysCement cement : filteredCements) {
            Map<String, Object> contentMap = new HashMap<>();
            contentMap.put("caocontent", cement.getCaoContent());
            contentMap.put("sio2content", cement.getSio2Content());
            contentMap.put("al2o3content", cement.getAl2o3Content());
            contents.add(contentMap);
        }

        // 统计型号数量（模糊匹配）
        int count525 = sysCementService.count(baseWrapper.clone().like("model", "52.5R"));
        int count425 = sysCementService.count(baseWrapper.clone().like("model", "42.5R"));

        Map<String, Integer> modelCounts = new HashMap<>();
        modelCounts.put("52.5R", count525);
        modelCounts.put("42.5R", count425);

        // 构造最终返回结果
        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("contents", contents);
        result.put("modelCounts", modelCounts);

        return AjaxResult.success(result);
    }


    /**
     * 查询砂
     * @param cementListDto
     * @return
     */

/*77
    @PostMapping("querySand")
    public AjaxResult querySand(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        // 如果 cityId 不为空，获取该市的所有下级区县 ID (level=3)
        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());
        }

        // 构造基础查询条件
        QueryWrapper<SysCement> baseWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            baseWrapper.in("region_name", districtIds);
        }

        // 查询所有砂数据
        List<SysSand> listSand = sysSandService.list();

        // 构造 contents 数组，放入CaO, SiO2, Al2O3含量（如你之前逻辑）
        List<Map<String, Object>> contents = new ArrayList<>();
        for (SysCement cement : sysCementService.list(baseWrapper)) {
            Map<String, Object> contentMap = new HashMap<>();
            contentMap.put("caocontent", cement.getCaoContent());
            contentMap.put("sio2content", cement.getSio2Content());
            contentMap.put("al2o3content", cement.getAl2o3Content());
            contents.add(contentMap);
        }

        // 统计型号数量（模糊匹配）
        int count525 = sysCementService.count(baseWrapper.clone().like("model", "52.5R"));
        int count425 = sysCementService.count(baseWrapper.clone().like("model", "42.5R"));

        Map<String, Integer> modelCounts = new HashMap<>();
        modelCounts.put("52.5R", count525);
        modelCounts.put("42.5R", count425);

        // 平均密度计算（以总条数为除数）
        int totalCount = listSand.size();
        BigDecimal bulkSum = BigDecimal.ZERO;
        BigDecimal compactSum = BigDecimal.ZERO;
        BigDecimal apparentSum = BigDecimal.ZERO;

        for (SysSand sand : listSand) {
            if (sand.getBulkDensity() != null) {
                bulkSum = bulkSum.add(sand.getBulkDensity());
            }
            if (sand.getCompactDensity() != null) {
                compactSum = compactSum.add(sand.getCompactDensity());
            }
            if (sand.getApparentDensity() != null) {
                apparentSum = apparentSum.add(sand.getApparentDensity());
            }
        }

        BigDecimal avgBulkDensity = totalCount == 0 ? BigDecimal.ZERO :
                bulkSum.divide(BigDecimal.valueOf(totalCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgCompactDensity = totalCount == 0 ? BigDecimal.ZERO :
                compactSum.divide(BigDecimal.valueOf(totalCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgApparentDensity = totalCount == 0 ? BigDecimal.ZERO :
                apparentSum.divide(BigDecimal.valueOf(totalCount), 2, RoundingMode.HALF_UP);

        // 构造最终返回结果
        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("contents", contents);
        result.put("modelCounts", modelCounts);
        result.put("平均堆积密度 (kg/m³)", avgBulkDensity);
        result.put("平均紧密密度 (kg/m³)", avgCompactDensity);
        result.put("平均表观密度 (kg/m³)", avgApparentDensity);
        return AjaxResult.success(result);
    }

*/

    /**
     * 查询砂
     *
     * @param cementListDto
     * @return
     */
    @PostMapping("querySand")
    public AjaxResult querySand(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());

            // 如果没有区县，则使用市区ID
            if (districtIds.isEmpty()) {
                districtIds.add(cityId);
            }
        }

        // 查询砂数据
        QueryWrapper<SysSand> sandWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            sandWrapper.in("region_name", districtIds);
        }
        List<SysSand> filteredSandList = sysSandService.list(sandWrapper);

        // 非零项平均计算
        BigDecimal bulkSum = BigDecimal.ZERO;
        BigDecimal compactSum = BigDecimal.ZERO;
        BigDecimal apparentSum = BigDecimal.ZERO;

        int bulkCount = 0, compactCount = 0, apparentCount = 0;

        for (SysSand sand : filteredSandList) {
            BigDecimal bulk = sand.getBulkDensity();
            if (bulk != null && bulk.compareTo(BigDecimal.ZERO) > 0) {
                bulkSum = bulkSum.add(bulk);
                bulkCount++;
            }

            BigDecimal compact = sand.getCompactDensity();
            if (compact != null && compact.compareTo(BigDecimal.ZERO) > 0) {
                compactSum = compactSum.add(compact);
                compactCount++;
            }

            BigDecimal apparent = sand.getApparentDensity();
            if (apparent != null && apparent.compareTo(BigDecimal.ZERO) > 0) {
                apparentSum = apparentSum.add(apparent);
                apparentCount++;
            }
        }

        BigDecimal avgBulk = bulkCount == 0 ? BigDecimal.ZERO :
                bulkSum.divide(BigDecimal.valueOf(bulkCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgCompact = compactCount == 0 ? BigDecimal.ZERO :
                compactSum.divide(BigDecimal.valueOf(compactCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgApparent = apparentCount == 0 ? BigDecimal.ZERO :
                apparentSum.divide(BigDecimal.valueOf(apparentCount), 2, RoundingMode.HALF_UP);

        // 准备类型关键词映射
        Map<String, String> typeKeywords = new LinkedHashMap<>();
        typeKeywords.put("细砂", "细");
        typeKeywords.put("中砂", "中");
        typeKeywords.put("粗砂", "粗");
        typeKeywords.put("天然砂", "天然砂");
        typeKeywords.put("机制砂", "机制砂");

        // 初始化计数器
        Map<String, Integer> modelCounts = new HashMap<>();
        typeKeywords.keySet().forEach(key -> modelCounts.put(key, 0));

        // 内存中过滤统计
        for (SysSand sand : filteredSandList) {
            String type = sand.getType();
            if (type == null) continue;

            for (Map.Entry<String, String> entry : typeKeywords.entrySet()) {
                String key = entry.getKey();
                String keyword = entry.getValue();
                if (type.contains(keyword)) {
                    modelCounts.put(key, modelCounts.get(key) + 1);
                    break;  // 一条记录只算一个类别
                }
            }
        }

        // 构造返回结果，去掉 contents
        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("modelCounts", modelCounts);
        result.put("平均堆积密度 (kg/m³)", avgBulk);
        result.put("平均紧密密度 (kg/m³)", avgCompact);
        result.put("平均表观密度 (kg/m³)", avgApparent);

        return AjaxResult.success(result);
    }


    /**
     * 查询石头
     *
     * @param cementListDto
     * @return
     */

    @PostMapping("queryStone")
    public AjaxResult queryStone(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());

            // 如果没有区县，则使用市区ID
            if (districtIds.isEmpty()) {
                districtIds.add(cityId);
            }
        }

        // 查询石头数据的条件
        QueryWrapper<SysStone> stoneWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            stoneWrapper.in("region_name", districtIds);
        }

        // 根据条件查询
        List<SysStone> filteredStoneList = sysStoneService.list(stoneWrapper);

        // 平均值计算初始化
        BigDecimal bulkSum = BigDecimal.ZERO;     // 堆积密度 stacking_density
        BigDecimal compactSum = BigDecimal.ZERO;  // 紧密密度 compact_density
        BigDecimal apparentSum = BigDecimal.ZERO; // 表观密度 bulkdensity

        int bulkCount = 0, compactCount = 0, apparentCount = 0;

        for (SysStone stone : filteredStoneList) {
            BigDecimal bulk = stone.getStackingDensity();
            if (bulk != null && bulk.compareTo(BigDecimal.ZERO) > 0) {
                bulkSum = bulkSum.add(bulk);
                bulkCount++;
            }

            BigDecimal compact = stone.getCompactDensity();
            if (compact != null && compact.compareTo(BigDecimal.ZERO) > 0) {
                compactSum = compactSum.add(compact);
                compactCount++;
            }

            BigDecimal apparent = stone.getBulkDensity();
            if (apparent != null && apparent.compareTo(BigDecimal.ZERO) > 0) {
                apparentSum = apparentSum.add(apparent);
                apparentCount++;
            }
        }

        BigDecimal avgBulk = bulkCount == 0 ? BigDecimal.ZERO :
                bulkSum.divide(BigDecimal.valueOf(bulkCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgCompact = compactCount == 0 ? BigDecimal.ZERO :
                compactSum.divide(BigDecimal.valueOf(compactCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgApparent = apparentCount == 0 ? BigDecimal.ZERO :
                apparentSum.divide(BigDecimal.valueOf(apparentCount), 2, RoundingMode.HALF_UP);

        // 类型关键词映射，用model字段匹配
        Map<String, String> typeKeywords = new LinkedHashMap<>();
        typeKeywords.put("石灰石", "石灰石");
        typeKeywords.put("黄岗岩", "黄岗岩");

        // 初始化计数器
        Map<String, Integer> modelCounts = new HashMap<>();
        typeKeywords.keySet().forEach(key -> modelCounts.put(key, 0));

        // 统计model类型数量
        for (SysStone stone : filteredStoneList) {
            String model = stone.getModel();
            if (model == null) {
                continue;
            }

            for (Map.Entry<String, String> entry : typeKeywords.entrySet()) {
                String key = entry.getKey();
                String keyword = entry.getValue();
                if (model.contains(keyword)) {
                    modelCounts.put(key, modelCounts.get(key) + 1);
                    break;  // 一条记录只算一个类别
                }
            }
        }

        // 构造返回结果
        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("modelCounts", modelCounts);
        result.put("平均堆积密度 (kg/m³)", avgBulk);
        result.put("平均紧密密度 (kg/m³)", avgCompact);
        result.put("平均表观密度 (kg/m³)", avgApparent);

        return AjaxResult.success(result);
    }


    /**
     * 查询粉煤灰
     *
     * @param cementListDto
     * @return
     */


    @PostMapping("queryFlyash")
    public AjaxResult queryFlyash(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());

            if (districtIds.isEmpty()) {
                districtIds.add(cityId);
            }
        }

        QueryWrapper<SysFlyash> flyashWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            flyashWrapper.in("region_name", districtIds);
        }

        flyashWrapper.select("grade");

        List<SysFlyash> flyashList = sysFlyashService.list(flyashWrapper);

        int countII = 0;
        int countIII = 0;

        for (SysFlyash flyash : flyashList) {
            String grade = flyash.getGrade();
            if (grade == null) {
                continue;
            }

            if (grade.contains("Ⅱ级")) {
                countII++;
            }
            if (grade.contains("Ⅲ级")) {
                countIII++;
            }
        }

        Map<String, Integer> modelCounts = new HashMap<>();
        modelCounts.put("Ⅱ级", countII);
        modelCounts.put("Ⅲ级", countIII);

        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("modelCounts", modelCounts);

        return AjaxResult.success(result);
    }


    /**
     * 查询石粉数据
     */

    @PostMapping("queryOtherAdmixtures")
    public AjaxResult queryOtherAdmixtures(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());

            if (districtIds.isEmpty()) {
                districtIds.add(cityId);
            }
        }

        QueryWrapper<SysOtherAdmixtures> wrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            wrapper.in("region_name", districtIds);
        }

        wrapper.select("model");  // 这里改成 model

        List<SysOtherAdmixtures> admixturesList = sysOtherAdmixturesService.list(wrapper);
        int countShihuiShi = 0;
        int countHuagangyan = 0;

        for (SysOtherAdmixtures admixture : admixturesList) {
            String model = admixture.getModel();
            if (model == null) {
                continue;
            }

            if (model.contains("石灰石")) {
                countShihuiShi++;
            }
            if (model.contains("花岗岩")) {
                countHuagangyan++;
            }
        }

        Map<String, Integer> modelCounts = new HashMap<>();
        modelCounts.put("石灰石", countShihuiShi);
        modelCounts.put("花岗岩", countHuagangyan);

        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("modelCounts", modelCounts);

        return AjaxResult.success(result);
    }


    /**
     * 查询矿粉
     *
     * @param cementListDto
     * @return
     */
    @PostMapping("queryMineralPowder")
    public AjaxResult queryMineralPowder(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());

            if (districtIds.isEmpty()) {
                districtIds.add(cityId);
            }
        }

        QueryWrapper<SysMineralPowder> wrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            wrapper.in("region_name", districtIds);
        }

        wrapper.select("model");  // 这里改成 model

        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list(wrapper);
        ;
        int countShihuiShi = 0;
        int countHuagangyan = 0;

        for (SysMineralPowder admixture : listMineralPowder) {
            String model = admixture.getModel();
            if (model == null) continue;

            if (model.contains("S95")) {
                countShihuiShi++;
            }
            if (model.contains("S105")) {
                countHuagangyan++;
            }
        }

        Map<String, Integer> modelCounts = new HashMap<>();
        modelCounts.put("S95", countShihuiShi);
        modelCounts.put("S105", countHuagangyan);

        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("modelCounts", modelCounts);

        return AjaxResult.success(result);
    }


    /**
     * 查询富余系数
     */


    @PostMapping("queryEnough")
    public AjaxResult queryEnough(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());

            if (districtIds.isEmpty()) {
                districtIds.add(cityId);
            }
        }

        QueryWrapper<SysMechanicalPerformance> wrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            wrapper.in("region", districtIds);
        }

        wrapper.select("compressive_28d", "strength_grade");

        List<SysMechanicalPerformance> list = sysMechanicalPerformanceService.list(wrapper);

        Map<String, List<SysMechanicalPerformance>> grouped = list.stream()
                .filter(item -> item.getStrengthGrade() != null && item.getCompressive28d() != null)
                .collect(Collectors.groupingBy(SysMechanicalPerformance::getStrengthGrade));

        List<Map<String, Object>> gradeStats = new ArrayList<>();

        for (Map.Entry<String, List<SysMechanicalPerformance>> entry : grouped.entrySet()) {
            String grade = entry.getKey();
            List<SysMechanicalPerformance> groupList = entry.getValue();

            String numericPart = grade.replaceAll("[^0-9.]", "");
            if (numericPart.isEmpty()) {
                continue;
            }

            BigDecimal gradeValue;
            try {
                gradeValue = new BigDecimal(numericPart);
            } catch (NumberFormatException e) {
                continue;
            }

            BigDecimal totalDiff = BigDecimal.ZERO;
            List<BigDecimal> compressives = new ArrayList<>();

            for (SysMechanicalPerformance item : groupList) {
                BigDecimal compressive = item.getCompressive28d();
                if (compressive != null) {
                    BigDecimal diff = compressive.subtract(gradeValue);
                    totalDiff = totalDiff.add(diff);
                    compressives.add(compressive);
                }
            }

            int count = compressives.size();
            BigDecimal avgDiff = count > 0
                    ? totalDiff.divide(BigDecimal.valueOf(count), 2, RoundingMode.HALF_UP)
                    : BigDecimal.ZERO;

            // 计算均值
            BigDecimal sum = compressives.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
            BigDecimal mean = count > 0
                    ? sum.divide(BigDecimal.valueOf(count), 2, RoundingMode.HALF_UP)
                    : BigDecimal.ZERO;

            // 计算标准差
            BigDecimal variance = BigDecimal.ZERO;
            for (BigDecimal value : compressives) {
                BigDecimal deviation = value.subtract(mean);
                BigDecimal squared = deviation.multiply(deviation);
                variance = variance.add(squared);
            }

            BigDecimal stdDev = count > 0
                    ? new BigDecimal(Math.sqrt(variance.divide(BigDecimal.valueOf(count), 6, RoundingMode.HALF_UP).doubleValue()))
                    : BigDecimal.ZERO;

            // 变异系数 = 标准差 / 均值
//            BigDecimal cv = mean.compareTo(BigDecimal.ZERO) != 0
//                    ? stdDev.divide(mean, 6, RoundingMode.HALF_UP)
//                    : BigDecimal.ZERO;
            // 变异系数 = 标准差 / 均值，乘以100并保留2位小数
            BigDecimal cv = mean.compareTo(BigDecimal.ZERO) != 0
                    ? stdDev.divide(mean, 6, RoundingMode.HALF_UP)
                    .multiply(BigDecimal.valueOf(100))
                    .setScale(2, RoundingMode.HALF_UP)
                    : BigDecimal.ZERO;


            Map<String, Object> stat = new HashMap<>();
            stat.put("strengthGrade", grade);
            stat.put("count", count);
            stat.put("totalDifference", totalDiff);
            stat.put("averageDifference", avgDiff);
            stat.put("averageCompressive", mean);
            stat.put("standardDeviation", stdDev);
            stat.put("coefficientOfVariation", cv); // CV

            gradeStats.add(stat);
        }

        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("strengthGradeStats", gradeStats);

        return AjaxResult.success(result);
    }

    /**
     * 查询总接口
     */

    @PostMapping("queryTotalByRegionId")
    public AjaxResult queryTotalByRegionId(@RequestBody CementListDto cementListDto) {


        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        // 如果 cityId 不为空，获取该市的所有下级区县 ID (level=3)
        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());
        }

        // 构造基础查询条件
        QueryWrapper<SysCement> baseWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            baseWrapper.in("region_name", districtIds);
        }

        // 查询所有符合条件的水泥数据
        List<SysCement> filteredCements = sysCementService.list(baseWrapper);

        // 构造 contents 数组，放入CaO, SiO2, Al2O3含量
        List<Map<String, Object>> Cementcontents = new ArrayList<>();
        for (SysCement cement : filteredCements) {
            Map<String, Object> contentMap = new HashMap<>();
            contentMap.put("caocontent", cement.getCaoContent());
            contentMap.put("sio2content", cement.getSio2Content());
            contentMap.put("al2o3content", cement.getAl2o3Content());
            Cementcontents.add(contentMap);
        }

        // 统计型号数量（模糊匹配）
        int count525 = sysCementService.count(baseWrapper.clone().like("model", "52.5R"));
        int count425 = sysCementService.count(baseWrapper.clone().like("model", "42.5R"));

        Map<String, Integer> CementmodelCounts = new HashMap<>();
        CementmodelCounts.put("CementFifth", count525);// 水泥52.5R
        CementmodelCounts.put("CementFourth", count425); //水泥42.5R

        // 构造最终返回结果
        Map<String, Object> resulCement = new HashMap<>();
        resulCement.put("cityId", cityId);
        resulCement.put("districtIds", districtIds);
        resulCement.put("Cementcontents", Cementcontents);//水泥 caocontent sio2content  al2o3content
        resulCement.put("CementmodelCounts", CementmodelCounts);

        Map<String, Object> resultTatal = new HashMap<>();
        resultTatal.put("Cement", resulCement);


        /*砂子*/
        // 查询砂数据
        QueryWrapper<SysSand> sandWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            sandWrapper.in("region_name", districtIds);
        }
        List<SysSand> filteredSandList = sysSandService.list(sandWrapper);

        // 非零项平均计算
        BigDecimal bulkSum = BigDecimal.ZERO;
        BigDecimal compactSum = BigDecimal.ZERO;
        BigDecimal apparentSum = BigDecimal.ZERO;

        int bulkCount = 0, compactCount = 0, apparentCount = 0;

        for (SysSand sand : filteredSandList) {
            BigDecimal bulk = sand.getBulkDensity();
            if (bulk != null && bulk.compareTo(BigDecimal.ZERO) > 0) {
                bulkSum = bulkSum.add(bulk);
                bulkCount++;
            }

            BigDecimal compact = sand.getCompactDensity();
            if (compact != null && compact.compareTo(BigDecimal.ZERO) > 0) {
                compactSum = compactSum.add(compact);
                compactCount++;
            }

            BigDecimal apparent = sand.getApparentDensity();
            if (apparent != null && apparent.compareTo(BigDecimal.ZERO) > 0) {
                apparentSum = apparentSum.add(apparent);
                apparentCount++;
            }
        }

        BigDecimal avgBulk = bulkCount == 0 ? BigDecimal.ZERO :
                bulkSum.divide(BigDecimal.valueOf(bulkCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgCompact = compactCount == 0 ? BigDecimal.ZERO :
                compactSum.divide(BigDecimal.valueOf(compactCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgApparent = apparentCount == 0 ? BigDecimal.ZERO :
                apparentSum.divide(BigDecimal.valueOf(apparentCount), 2, RoundingMode.HALF_UP);

        // 准备类型关键词映射
        Map<String, String> typeKeywords = new LinkedHashMap<>();
        typeKeywords.put("sandFine", "细");//细砂
        typeKeywords.put("sandMiddle", "中");//中砂
        typeKeywords.put("sandThick", "粗");//粗砂
        typeKeywords.put("sandNatural", "天然砂");//天然砂
        typeKeywords.put("sandMachine", "机制砂");//机制砂

        // 初始化计数器
        Map<String, Integer> modelCounts = new HashMap<>();
        typeKeywords.keySet().forEach(key -> modelCounts.put(key, 0));

        // 内存中过滤统计
        for (SysSand sand : filteredSandList) {
            String type = sand.getType();
            if (type == null) {
                continue;
            }

            for (Map.Entry<String, String> entry : typeKeywords.entrySet()) {
                String key = entry.getKey();
                String keyword = entry.getValue();
                if (type.contains(keyword)) {
                    modelCounts.put(key, modelCounts.get(key) + 1);
                    break;  // 一条记录只算一个类别
                }
            }
        }


        Map<String, Object> resultSand = new HashMap<>();


        // 构造返回结果，去掉 contents
        resultSand.put("cityId", cityId);
        resultSand.put("sandDistrictIds", districtIds);
        resultSand.put("sandModelCounts", modelCounts);
        resultSand.put("sandStore", avgBulk); //平均堆积密度 (kg/m³)
        resultSand.put("sandTightness", avgCompact);//平均紧密密度 (kg/m³)
        resultSand.put("sandApparent", avgApparent);//平均表观密度 (kg/m³)
        resultTatal.put("Sand", resultSand);
        /*------------------------石头----------------------------------------*/


// 查询石头数据的条件
        QueryWrapper<SysStone> stoneWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            stoneWrapper.in("region_name", districtIds);
        }

// 查询石头数据列表
        List<SysStone> filteredStoneList = sysStoneService.list(stoneWrapper);

// 初始化密度求和及计数
        BigDecimal sandStackingSum = BigDecimal.ZERO;   // 堆积密度
        BigDecimal sandCompactSum = BigDecimal.ZERO;    // 紧密密度
        BigDecimal sandApparentSum = BigDecimal.ZERO;   // 表观密度

        int sandStackingCount = 0;
        int sandCompactCount = 0;
        int sandApparentCount = 0;

// 遍历数据计算总和与数量
        for (SysStone stone : filteredStoneList) {
            BigDecimal stacking = stone.getStackingDensity();
            if (stacking != null && stacking.compareTo(BigDecimal.ZERO) > 0) {
                sandStackingSum = sandStackingSum.add(stacking);
                sandStackingCount++;
            }

            BigDecimal compact = stone.getCompactDensity();
            if (compact != null && compact.compareTo(BigDecimal.ZERO) > 0) {
                sandCompactSum = sandCompactSum.add(compact);
                sandCompactCount++;
            }

            BigDecimal apparent = stone.getBulkDensity();
            if (apparent != null && apparent.compareTo(BigDecimal.ZERO) > 0) {
                sandApparentSum = sandApparentSum.add(apparent);
                sandApparentCount++;
            }
        }

// 平均值计算，保留两位小数
        BigDecimal avgSandStacking = sandStackingCount == 0
                ? BigDecimal.ZERO
                : sandStackingSum.divide(BigDecimal.valueOf(sandStackingCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgSandCompact = sandCompactCount == 0
                ? BigDecimal.ZERO
                : sandCompactSum.divide(BigDecimal.valueOf(sandCompactCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgSandApparent = sandApparentCount == 0
                ? BigDecimal.ZERO
                : sandApparentSum.divide(BigDecimal.valueOf(sandApparentCount), 2, RoundingMode.HALF_UP);

// 类型关键词映射（用于 model 字段匹配）
        Map<String, String> sandTypeKeywords = new LinkedHashMap<>();
        sandTypeKeywords.put("limeStone", "石灰石");
        sandTypeKeywords.put("huangGangYan", "黄岗岩");

// 初始化类型统计器
        Map<String, Integer> sandModelCounts = new HashMap<>();
        sandTypeKeywords.keySet().forEach(key -> sandModelCounts.put(key, 0));

// 遍历统计 model 类型数量
        for (SysStone stone : filteredStoneList) {
            String model = stone.getModel();
            if (model == null) {
                continue;
            }

            for (Map.Entry<String, String> entry : sandTypeKeywords.entrySet()) {
                String key = entry.getKey();
                String keyword = entry.getValue();
                if (model.contains(keyword)) {
                    sandModelCounts.put(key, sandModelCounts.get(key) + 1);
                    break; // 一个 model 只匹配一个类型
                }
            }
        }

// 构造最终返回结果
        Map<String, Object> sandResult = new HashMap<>();
        sandResult.put("cityId", cityId);
        sandResult.put("districtIds", districtIds);
        sandResult.put("StonemodelCounts", sandModelCounts);
        sandResult.put("avgStackingDensity", avgSandStacking);   // 平均堆积密度 kg/m³
        sandResult.put("avgCompactDensity", avgSandCompact);     // 平均紧密密度 kg/m³
        sandResult.put("avgApparentDensity", avgSandApparent);   // 平均表观密度 kg/m³

// 存入总结果对象中
        resultTatal.put("Stone", sandResult);

        /*----------------------------粉煤灰-------------------------------------------*/


        // 查询所有地区

        QueryWrapper<SysFlyash> flyashWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            flyashWrapper.in("region_name", districtIds);
        }

        flyashWrapper.select("grade");

        List<SysFlyash> flyashList = sysFlyashService.list(flyashWrapper);

        int countII = 0;
        int countIII = 0;

        for (SysFlyash flyash : flyashList) {
            String grade = flyash.getGrade();
            if (grade != null) {
                if (grade.contains("Ⅱ级")) {
                    countII++;
                }
                if (grade.contains("Ⅲ级")) {
                    countIII++;
                }
            }

        }

        Map<String, Integer> modelCounts1 = new HashMap<>();
        modelCounts1.put("second", countII); //Ⅱ级
        modelCounts1.put("third", countIII); //Ⅲ级


        Map<String, Object> flyashResult = new HashMap<>();
        flyashResult.put("cityId", cityId);
        flyashResult.put("districtIds", districtIds);
        flyashResult.put("modelCounts", modelCounts1);


        resultTatal.put("Flyash", flyashResult);

        /*------------------------------------石粉---------------------------------------------*/

        QueryWrapper<SysOtherAdmixtures> wrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            wrapper.in("region_name", districtIds);
        }

        wrapper.select("model");  // 这里改成 model

        List<SysOtherAdmixtures> admixturesList = sysOtherAdmixturesService.list(wrapper);
        int countShihuiShi = 0;
        int countHuagangyan = 0;

        for (SysOtherAdmixtures admixture : admixturesList) {
            String model = admixture.getModel();
            if (model == null) {
                continue;
            }

            if (model.contains("石灰石")) {
                countShihuiShi++;
            }
            if (model.contains("花岗岩")) {
                countHuagangyan++;
            }
        }

        Map<String, Integer> modelCounts2 = new HashMap<>();
        modelCounts2.put("limeStone", countShihuiShi);  //石灰石
        modelCounts2.put("huangGangYan", countHuagangyan); //花岗岩

        Map<String, Object> resultOtherAdmixtures = new HashMap<>();
        resultOtherAdmixtures.put("cityId", cityId);
        resultOtherAdmixtures.put("districtIds", districtIds);
        resultOtherAdmixtures.put("modelCounts", modelCounts2);


        resultTatal.put("OtherAdmixtures", resultOtherAdmixtures);

        /*------------------------矿粉-------------------------------------*/

        QueryWrapper<SysMineralPowder> wrapper1 = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            wrapper1.in("region_name", districtIds);
        }

        wrapper1.select("model");  // 这里改成 model

        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list(wrapper1);
        ;
        int countShihuiShi1 = 0;
        int countHuagangyan1 = 0;

        for (SysMineralPowder admixture : listMineralPowder) {
            String model = admixture.getModel();
            if (model == null) {
                continue;
            }

            if (model.contains("S95")) {
                countShihuiShi1++;
            }
            if (model.contains("S105")) {
                countHuagangyan1++;
            }
        }

        Map<String, Integer> modelCounts3 = new HashMap<>();
        modelCounts3.put("sNineFive", countShihuiShi1);//Sninefif S95
        modelCounts3.put("sOneZeroFive", countHuagangyan1);//S 105

        Map<String, Object> resultMineralPowder = new HashMap<>();
        resultMineralPowder.put("cityId", cityId);
        resultMineralPowder.put("districtIds", districtIds);
        resultMineralPowder.put("modelCounts", modelCounts3);


        resultTatal.put("MineralPowder", resultMineralPowder);
        /*-----------------------------------查询富余变异----------------------------------------------------*/

        QueryWrapper<SysMechanicalPerformance> wrapper5 = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            wrapper5.in("region", districtIds);
        }

        wrapper5.select("compressive_28d", "strength_grade");

        List<SysMechanicalPerformance> list = sysMechanicalPerformanceService.list(wrapper5);

        Map<String, List<SysMechanicalPerformance>> grouped = list.stream()
                .filter(item -> item.getStrengthGrade() != null && item.getCompressive28d() != null)
                .collect(Collectors.groupingBy(SysMechanicalPerformance::getStrengthGrade));

        List<Map<String, Object>> gradeStats = new ArrayList<>();

        for (Map.Entry<String, List<SysMechanicalPerformance>> entry : grouped.entrySet()) {
            String grade = entry.getKey();
            List<SysMechanicalPerformance> groupList = entry.getValue();

            String numericPart = grade.replaceAll("[^0-9.]", "");
            if (numericPart.isEmpty()) {
                continue;
            }

            BigDecimal gradeValue;
            try {
                gradeValue = new BigDecimal(numericPart);
            } catch (NumberFormatException e) {
                continue;
            }

            BigDecimal totalDiff = BigDecimal.ZERO;
            List<BigDecimal> compressives = new ArrayList<>();

            for (SysMechanicalPerformance item : groupList) {
                BigDecimal compressive = item.getCompressive28d();
                if (compressive != null) {
                    BigDecimal diff = compressive.subtract(gradeValue);
                    totalDiff = totalDiff.add(diff);
                    compressives.add(compressive);
                }
            }

            int count = compressives.size();
            BigDecimal avgDiff = count > 0
                    ? totalDiff.divide(BigDecimal.valueOf(count), 2, RoundingMode.HALF_UP)
                    : BigDecimal.ZERO;

            // 计算均值
            BigDecimal sum = compressives.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
            BigDecimal mean = count > 0
                    ? sum.divide(BigDecimal.valueOf(count), 2, RoundingMode.HALF_UP)
                    : BigDecimal.ZERO;

            // 计算标准差
            BigDecimal variance = BigDecimal.ZERO;
            for (BigDecimal value : compressives) {
                BigDecimal deviation = value.subtract(mean);
                BigDecimal squared = deviation.multiply(deviation);
                variance = variance.add(squared);
            }

            BigDecimal stdDev = count > 0
                    ? new BigDecimal(Math.sqrt(variance.divide(BigDecimal.valueOf(count), 6, RoundingMode.HALF_UP).doubleValue()))
                    : BigDecimal.ZERO;

            // 变异系数 = 标准差 / 均值
//            BigDecimal cv = mean.compareTo(BigDecimal.ZERO) != 0
//                    ? stdDev.divide(mean, 6, RoundingMode.HALF_UP)
//                    : BigDecimal.ZERO;
            // 变异系数 = 标准差 / 均值，乘以100并保留2位小数
            BigDecimal cv = mean.compareTo(BigDecimal.ZERO) != 0
                    ? stdDev.divide(mean, 6, RoundingMode.HALF_UP)
                    .multiply(BigDecimal.valueOf(100))
                    .setScale(2, RoundingMode.HALF_UP)
                    : BigDecimal.ZERO;


            Map<String, Object> stat = new HashMap<>();
            stat.put("strengthGrade", grade);
            stat.put("count", count);
            stat.put("totalDifference", totalDiff);
            stat.put("averageDifference", avgDiff);
            stat.put("averageCompressive", mean);
            stat.put("standardDeviation", stdDev);
            stat.put("coefficientOfVariation", cv); // CV

            gradeStats.add(stat);
        }

        Map<String, Object> resultEnoughVariation = new HashMap<>();
        resultEnoughVariation.put("cityId", cityId);
        resultEnoughVariation.put("districtIds", districtIds);
        resultEnoughVariation.put("strengthGradeStats", gradeStats);

        resultTatal.put("EnoughVariation", resultEnoughVariation);


        return AjaxResult.success(resultTatal);
    }






/* 查询富余系数666
    @PostMapping("queryEnough")
    public AjaxResult queryEnough(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());

            if (districtIds.isEmpty()) {
                districtIds.add(cityId);
            }
        }

        QueryWrapper<SysMechanicalPerformance> wrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            wrapper.in("region", districtIds);
        }

        // 查询 compressive28d 和 strength_grade 字段
        wrapper.select("compressive_28d", "strength_grade");

        List<SysMechanicalPerformance> list = sysMechanicalPerformanceService.list(wrapper);

        // 分组：按 strengthGrade
        Map<String, List<SysMechanicalPerformance>> grouped = list.stream()
                .filter(item -> item.getStrengthGrade() != null && item.getCompressive28d() != null)
                .collect(Collectors.groupingBy(SysMechanicalPerformance::getStrengthGrade));

        List<Map<String, Object>> gradeStats = new ArrayList<>();

        for (Map.Entry<String, List<SysMechanicalPerformance>> entry : grouped.entrySet()) {
            String grade = entry.getKey();
            List<SysMechanicalPerformance> groupList = entry.getValue();

            // 提取 C 后的数字部分
            String numericPart = grade.replaceAll("[^0-9.]", "");
            if (numericPart.isEmpty()) continue;

            BigDecimal gradeValue;
            try {
                gradeValue = new BigDecimal(numericPart);
            } catch (NumberFormatException e) {
                continue; // 如果解析失败则跳过
            }

            BigDecimal totalDiff = BigDecimal.ZERO;
            int count = 0;

            for (SysMechanicalPerformance item : groupList) {
                BigDecimal compressive = item.getCompressive28d();
                if (compressive != null) {
                    BigDecimal diff = compressive.subtract(gradeValue);
                    totalDiff = totalDiff.add(diff);
                    count++;
                }
            }

            BigDecimal avgDiff = count > 0
                    ? totalDiff.divide(BigDecimal.valueOf(count), 2, RoundingMode.HALF_UP)
                    : BigDecimal.ZERO;

            Map<String, Object> stat = new HashMap<>();
            stat.put("strengthGrade", grade);
            stat.put("totalDifference", totalDiff);
            stat.put("count", count);
            stat.put("averageDifference", avgDiff);

            gradeStats.add(stat);
        }

        // 返回结构封装
        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("strengthGradeStats", gradeStats);


        return AjaxResult.success(result);
    }
*/



/*007
    @PostMapping("querySand")
    public AjaxResult querySand(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            // 先找三级区县
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());

            // 如果没有区县，放市ID自己
            if (districtIds.isEmpty()) {
                districtIds.add(cityId);
            }
        }

        // 查询砂数据
        QueryWrapper<SysSand> sandWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            sandWrapper.in("region_name", districtIds);
        }
        List<SysSand> filteredSandList = sysSandService.list(sandWrapper);

        // 非零项平均计算
        BigDecimal bulkSum = BigDecimal.ZERO;
        BigDecimal compactSum = BigDecimal.ZERO;
        BigDecimal apparentSum = BigDecimal.ZERO;

        int bulkCount = 0, compactCount = 0, apparentCount = 0;

        for (SysSand sand : filteredSandList) {
            BigDecimal bulk = sand.getBulkDensity();
            if (bulk != null && bulk.compareTo(BigDecimal.ZERO) > 0) {
                bulkSum = bulkSum.add(bulk);
                bulkCount++;
            }

            BigDecimal compact = sand.getCompactDensity();
            if (compact != null && compact.compareTo(BigDecimal.ZERO) > 0) {
                compactSum = compactSum.add(compact);
                compactCount++;
            }

            BigDecimal apparent = sand.getApparentDensity();
            if (apparent != null && apparent.compareTo(BigDecimal.ZERO) > 0) {
                apparentSum = apparentSum.add(apparent);
                apparentCount++;
            }
        }

        BigDecimal avgBulk = bulkCount == 0 ? BigDecimal.ZERO :
                bulkSum.divide(BigDecimal.valueOf(bulkCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgCompact = compactCount == 0 ? BigDecimal.ZERO :
                compactSum.divide(BigDecimal.valueOf(compactCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgApparent = apparentCount == 0 ? BigDecimal.ZERO :
                apparentSum.divide(BigDecimal.valueOf(apparentCount), 2, RoundingMode.HALF_UP);

        // 统计砂类型数量，模糊匹配type字段
        Map<String, String> typeKeywords = new LinkedHashMap<>();
        typeKeywords.put("细砂", "细");
        typeKeywords.put("中砂", "中");
        typeKeywords.put("粗砂", "粗");
        typeKeywords.put("天然砂", "天然砂");
        typeKeywords.put("机制砂", "机制砂");

        Map<String, Integer> modelCounts = new HashMap<>();

        for (Map.Entry<String, String> entry : typeKeywords.entrySet()) {
            String key = entry.getKey();
            String keyword = entry.getValue();

            QueryWrapper<SysSand> typeWrapper = new QueryWrapper<>();
            if (!districtIds.isEmpty()) {
                typeWrapper.in("region_name", districtIds);
            }
            typeWrapper.like("type", keyword);

            int count = sysSandService.count(typeWrapper);
            modelCounts.put(key, count);
        }

        // 构造返回结果，去掉 contents
        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("modelCounts", modelCounts);
        result.put("平均堆积密度 (kg/m³)", avgBulk);
        result.put("平均紧密密度 (kg/m³)", avgCompact);
        result.put("平均表观密度 (kg/m³)", avgApparent);

        return AjaxResult.success(result);
    }
*/

/*
    @PostMapping("querySand")
    public AjaxResult querySand(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            // 找所有区县ID
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());

            // 不管有没有区县，都要加上市区ID
            districtIds.add(cityId);
        }

        // 构建砂查询条件
        QueryWrapper<SysSand> sandWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            sandWrapper.in("region_name", districtIds);
        }

        // 查询砂数据
        List<SysSand> filteredSandList = sysSandService.list(sandWrapper);

        // 非零项平均计算
        BigDecimal bulkSum = BigDecimal.ZERO;
        BigDecimal compactSum = BigDecimal.ZERO;
        BigDecimal apparentSum = BigDecimal.ZERO;

        int bulkCount = 0, compactCount = 0, apparentCount = 0;

        for (SysSand sand : filteredSandList) {
            BigDecimal bulk = sand.getBulkDensity();
            if (bulk != null && bulk.compareTo(BigDecimal.ZERO) > 0) {
                bulkSum = bulkSum.add(bulk);
                bulkCount++;
            }

            BigDecimal compact = sand.getCompactDensity();
            if (compact != null && compact.compareTo(BigDecimal.ZERO) > 0) {
                compactSum = compactSum.add(compact);
                compactCount++;
            }

            BigDecimal apparent = sand.getApparentDensity();
            if (apparent != null && apparent.compareTo(BigDecimal.ZERO) > 0) {
                apparentSum = apparentSum.add(apparent);
                apparentCount++;
            }
        }

        BigDecimal avgBulk = bulkCount == 0 ? BigDecimal.ZERO :
                bulkSum.divide(BigDecimal.valueOf(bulkCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgCompact = compactCount == 0 ? BigDecimal.ZERO :
                compactSum.divide(BigDecimal.valueOf(compactCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgApparent = apparentCount == 0 ? BigDecimal.ZERO :
                apparentSum.divide(BigDecimal.valueOf(apparentCount), 2, RoundingMode.HALF_UP);

        // Cement 查询与模型统计
        QueryWrapper<SysCement> cementWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            cementWrapper.in("region_name", districtIds);
        }

        int count525 = sysSandService.count(cementWrapper.clone().like("model", "52.5R"));
        int count425 = sysSandService.count(cementWrapper.clone().like("model", "42.5R"));

        Map<String, Integer> modelCounts = new HashMap<>();
        modelCounts.put("52.5R", count525);
        modelCounts.put("42.5R", count425);

        // contents 构建
        List<Map<String, Object>> contents = new ArrayList<>();
        for (SysSand sand : filteredSandList) {
            Map<String, Object> contentMap = new HashMap<>();
            contentMap.put("fineness", sand.getFineness());
            contentMap.put("bulkDensity", sand.getBulkDensity());
            contentMap.put("compactDensity", sand.getCompactDensity());
            contents.add(contentMap);
        }

        // 构造返回结果
        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("contents", contents);
        result.put("modelCounts", modelCounts);
        result.put("平均堆积密度 (kg/m³)", avgBulk);
        result.put("平均紧密密度 (kg/m³)", avgCompact);
        result.put("平均表观密度 (kg/m³)", avgApparent);

        return AjaxResult.success(result);
    }
*/

/*
    @PostMapping("/querySand")
    public AjaxResult querySand(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());

            if (districtIds.isEmpty()) {
                // 没有区县，直接用市级ID查询
                districtIds.add(cityId);
            }
        }


        // 构建砂查询条件
        QueryWrapper<SysSand> sandWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            sandWrapper.in("region_name", districtIds);
        }

        // 查询砂数据
        List<SysSand> filteredSandList = sysSandService.list(sandWrapper);

        // 非零项平均计算
        BigDecimal bulkSum = BigDecimal.ZERO;
        BigDecimal compactSum = BigDecimal.ZERO;
        BigDecimal apparentSum = BigDecimal.ZERO;

        int bulkCount = 0, compactCount = 0, apparentCount = 0;

        for (SysSand sand : filteredSandList) {
            BigDecimal bulk = sand.getBulkDensity();
            if (bulk != null && bulk.compareTo(BigDecimal.ZERO) > 0) {
                bulkSum = bulkSum.add(bulk);
                bulkCount++;
            }

            BigDecimal compact = sand.getCompactDensity();
            if (compact != null && compact.compareTo(BigDecimal.ZERO) > 0) {
                compactSum = compactSum.add(compact);
                compactCount++;
            }

            BigDecimal apparent = sand.getApparentDensity();
            if (apparent != null && apparent.compareTo(BigDecimal.ZERO) > 0) {
                apparentSum = apparentSum.add(apparent);
                apparentCount++;
            }
        }

        BigDecimal avgBulk = bulkCount == 0 ? BigDecimal.ZERO :
                bulkSum.divide(BigDecimal.valueOf(bulkCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgCompact = compactCount == 0 ? BigDecimal.ZERO :
                compactSum.divide(BigDecimal.valueOf(compactCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgApparent = apparentCount == 0 ? BigDecimal.ZERO :
                apparentSum.divide(BigDecimal.valueOf(apparentCount), 2, RoundingMode.HALF_UP);

        // Cement 查询与模型统计
        QueryWrapper<SysCement> cementWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            cementWrapper.in("region_name", districtIds);
        } else if (cityId != null) {
            cementWrapper.eq("region_name", cityId);
        }

        int count525 = sysCementService.count(cementWrapper.clone().like("model", "52.5R"));
        int count425 = sysCementService.count(cementWrapper.clone().like("model", "42.5R"));

        Map<String, Integer> modelCounts = new HashMap<>();
        modelCounts.put("52.5R", count525);
        modelCounts.put("42.5R", count425);

        // contents 构建
        List<Map<String, Object>> contents = new ArrayList<>();
        for (SysSand sand : filteredSandList) {
            Map<String, Object> contentMap = new HashMap<>();
            contentMap.put("fineness", sand.getFineness());
            contentMap.put("bulkDensity", sand.getBulkDensity());
            contentMap.put("compactDensity", sand.getCompactDensity());
            contents.add(contentMap);
        }

        // 构造返回结果
        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("contents", contents);
        result.put("modelCounts", modelCounts);
        result.put("平均堆积密度 (kg/m³)", avgBulk);
        result.put("平均紧密密度 (kg/m³)", avgCompact);
        result.put("平均表观密度 (kg/m³)", avgApparent);

        return AjaxResult.success(result);
    }
*/


/*
    @PostMapping("querySand")
    public AjaxResult querySand(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());
        }

        // 构建砂查询条件
        QueryWrapper<SysSand> sandWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            sandWrapper.in("region_name", districtIds);
        }

        List<SysSand> filteredSandList = sysSandService.list(sandWrapper);

        // 非零项平均密度统计
        BigDecimal bulkSum = BigDecimal.ZERO;
        BigDecimal compactSum = BigDecimal.ZERO;
        BigDecimal apparentSum = BigDecimal.ZERO;

        int bulkCount = 0;
        int compactCount = 0;
        int apparentCount = 0;

        for (SysSand sand : filteredSandList) {
            BigDecimal bulk = sand.getBulkDensity();
            if (bulk != null && bulk.compareTo(BigDecimal.ZERO) > 0) {
                bulkSum = bulkSum.add(bulk);
                bulkCount++;
            }

            BigDecimal compact = sand.getCompactDensity();
            if (compact != null && compact.compareTo(BigDecimal.ZERO) > 0) {
                compactSum = compactSum.add(compact);
                compactCount++;
            }

            BigDecimal apparent = sand.getApparentDensity();
            if (apparent != null && apparent.compareTo(BigDecimal.ZERO) > 0) {
                apparentSum = apparentSum.add(apparent);
                apparentCount++;
            }
        }

        BigDecimal avgBulk = bulkCount == 0 ? BigDecimal.ZERO :
                bulkSum.divide(BigDecimal.valueOf(bulkCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgCompact = compactCount == 0 ? BigDecimal.ZERO :
                compactSum.divide(BigDecimal.valueOf(compactCount), 2, RoundingMode.HALF_UP);

        BigDecimal avgApparent = apparentCount == 0 ? BigDecimal.ZERO :
                apparentSum.divide(BigDecimal.valueOf(apparentCount), 2, RoundingMode.HALF_UP);

        // 模型计数
        QueryWrapper<SysCement> baseWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            baseWrapper.in("region_name", districtIds);
        } else if (cityId != null) {
            baseWrapper.eq("region_name", cityId); // 兜底逻辑
        }

        int count525 = sysCementService.count(baseWrapper.clone().like("model", "52.5R"));
        int count425 = sysCementService.count(baseWrapper.clone().like("model", "42.5R"));

        Map<String, Integer> modelCounts = new HashMap<>();
        modelCounts.put("52.5R", count525);
        modelCounts.put("42.5R", count425);

        // 可选内容构建
        List<SysCement> filteredCements = sysCementService.list(baseWrapper);
        List<Map<String, Object>> contents = new ArrayList<>();
        for (SysCement cement : filteredCements) {
            Map<String, Object> contentMap = new HashMap<>();
            contentMap.put("caocontent", cement.getCaoContent());
            contentMap.put("sio2content", cement.getSio2Content());
            contentMap.put("al2o3content", cement.getAl2o3Content());
            contents.add(contentMap);
        }

        // 构造返回结构
        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("contents", contents);
        result.put("modelCounts", modelCounts);
        result.put("平均堆积密度 (kg/m³)", avgBulk);
        result.put("平均紧密密度 (kg/m³)", avgCompact);
        result.put("平均表观密度 (kg/m³)", avgApparent);

        return AjaxResult.success(result);
    }
*/



/*
    @PostMapping("querySand")
    public AjaxResult querySand(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());
        }

        QueryWrapper<SysSand> baseWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            baseWrapper.in("region_name", districtIds);
        }

        // 查询所有符合条件的砂数据
        List<SysSand> filteredSands = sysSandService.list(baseWrapper);

        // 构造 contents 数组，可根据实际需求调整
        List<Map<String, Object>> contents = new ArrayList<>();
        for (SysSand sand : filteredSands) {
            Map<String, Object> contentMap = new HashMap<>();
            contentMap.put("fineness", sand.getFineness());
            contentMap.put("bulkDensity", sand.getBulkDensity());
            contentMap.put("compactDensity", sand.getCompactDensity());
            contents.add(contentMap);
        }

        // 归类统计砂类型
        Map<String, Integer> typeCounts = new HashMap<>();
        // 初始化统计字段
        typeCounts.put("细砂", 0);
        typeCounts.put("中砂", 0);
        typeCounts.put("粗砂", 0);
        typeCounts.put("天然砂", 0);
        typeCounts.put("机制砂", 0);

        for (SysSand sand : filteredSands) {
            String type = sand.getType();
            if (type == null) continue;

            if (type.contains("细")) {
                typeCounts.put("细砂", typeCounts.get("细砂") + 1);
            } else if (type.contains("中")) {
                typeCounts.put("中砂", typeCounts.get("中砂") + 1);
            } else if (type.contains("粗")) {
                typeCounts.put("粗砂", typeCounts.get("粗砂") + 1);
            }

            if (type.contains("天然砂")) {
                typeCounts.put("天然砂", typeCounts.get("天然砂") + 1);
            }

            if (type.contains("机制砂")) {
                typeCounts.put("机制砂", typeCounts.get("机制砂") + 1);
            }
        }

        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("contents", contents);
        result.put("typeCounts", typeCounts);


        return AjaxResult.success(result);
    }
*/

/*
    @PostMapping("querySand")
    public AjaxResult querySand(@RequestBody CementListDto cementListDto) {
        Integer cityId = cementListDto.getId();

        // 查询所有地区
        List<Region> regionList = regionService.list();
        List<Integer> districtIds = new ArrayList<>();

        if (cityId != null) {
            districtIds = regionList.stream()
                    .filter(r -> r.getLevel() == 3 && cityId.equals(r.getParentId()))
                    .map(Region::getId)
                    .collect(Collectors.toList());
        }

        QueryWrapper<SysSand> baseWrapper = new QueryWrapper<>();
        if (!districtIds.isEmpty()) {
            baseWrapper.in("region_name", districtIds);
        }

        List<SysSand> filteredSands = sysSandService.list(baseWrapper);

        List<Map<String, Object>> contents = new ArrayList<>();
        for (SysSand sand : filteredSands) {
            Map<String, Object> contentMap = new HashMap<>();
            contentMap.put("fineness", sand.getFineness());
            contentMap.put("bulkDensity", sand.getBulkDensity());
            contentMap.put("compactDensity", sand.getCompactDensity());
            contents.add(contentMap);
        }

        // 多种类型统计
        Map<String, Integer> typeCounts = new HashMap<>();
        String[] sandTypes = {"细砂", "中砂", "粗砂", "天然砂", "机制砂"};
        for (String type : sandTypes) {
            int count = sysSandService.count(baseWrapper.clone().like("type", type));
            typeCounts.put(type, count);
        }

        Map<String, Object> result = new HashMap<>();
        result.put("cityId", cityId);
        result.put("districtIds", districtIds);
        result.put("contents", contents);
        result.put("typeCounts", typeCounts);

        return AjaxResult.success(result);
    }

*/


    /**
     * 导出原材料excel
     *
     * @param rawMaterialsDTO
     * @return
     * @throws IOException
     * @throws UnsupportedEncodingException
     */
    @PostMapping("exportRawMaterialsExcel")
    public ResponseEntity<byte[]> exportRawMaterialsExcel(@RequestBody RawMaterialsDTO rawMaterialsDTO) throws IOException, UnsupportedEncodingException {
        // 获取各类原材料的 ID 列表
        List<Integer> cementIds = rawMaterialsDTO.getCementIds();
        List<Integer> sandIds = rawMaterialsDTO.getSandIds();
        List<Integer> stoneIds = rawMaterialsDTO.getStoneIds();
        List<Integer> flyashIds = rawMaterialsDTO.getFlyashIds();
        List<Integer> waterReducerIds = rawMaterialsDTO.getWaterReducerIds();

        // 根据 ID 列表查询数据
        List<SysCement> cementList = sysCementService.listCementByIds(cementIds);
        List<SysStone> stoneList = sysStoneService.listStoneByIds(stoneIds);
        List<SysSand> sandList = sysSandService.listSandByIds(sandIds);
        List<SysFlyash> flyashList = sysFlyashService.listFlyashIds(flyashIds);
        List<SysWaterReducer> waterReducerList = sysWaterReducerService.listWaterReduceIds(waterReducerIds);

        //矿粉
        List<Integer> powderIds = rawMaterialsDTO.getPowderIds();
        LambdaQueryWrapper<SysMineralPowder> wrapper = new LambdaQueryWrapper<>();
        if (powderIds != null && !powderIds.isEmpty()) {
            wrapper.in(SysMineralPowder::getPowderId, powderIds);
        } else {
            // 如果 swellingagentIds 为空，添加一个永假条件（如 1=0）
            wrapper.apply("1 = 0");
        }
        List<SysMineralPowder> MineralPowderList = sysMineralPowderService.list(wrapper);


        //石粉
        List<Integer> admixturesIds = rawMaterialsDTO.getAdmixturesIds();
        LambdaQueryWrapper<SysOtherAdmixtures> wrapperPowder = new LambdaQueryWrapper<>();
        if (admixturesIds != null && !admixturesIds.isEmpty()) {
            wrapperPowder.in(SysOtherAdmixtures::getAdmixturesId, admixturesIds);
        } else {
            // 如果 swellingagentIds 为空，添加一个永假条件（如 1=0）
            wrapper.apply("1 = 0");
        }
        List<SysOtherAdmixtures> OtherAdmixtureslist = sysOtherAdmixturesService.list(wrapperPowder);


        // 创建一个 Excel 工作簿
        Workbook workbook = new XSSFWorkbook();
        // 创建不同 sheet 并填充数据
        createCementSheet(workbook, cementList);
        createStoneSheet(workbook, stoneList);
/*        createSandSheet(workbook, sandList);
        createFlyashSheet(workbook, flyashList);
      //  createWaterReducerSheet(workbook, waterReducerList);

        createPowderSheet(workbook, MineralPowderList);

        createFlyashSheet1(workbook, OtherAdmixtureslist);*/


        // 将 Excel 数据写入字节数组输出流
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        workbook.write(byteArrayOutputStream);
        byteArrayOutputStream.close();

        byte[] excelData = byteArrayOutputStream.toByteArray();
        String fileName = "原材料数据.xlsx";

        // 对文件名进行 URL 编码
        String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");

        // 设置响应头，返回 Excel 文件
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Disposition", "attachment; filename=" + encodedFileName);
        headers.add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

        return ResponseEntity.ok()
                .headers(headers)
                .body(excelData);
    }

    // 工具方法：创建水泥 sheet
    private void createCementSheet(Workbook workbook, List<SysCement> cementList) {
        Sheet sheet = workbook.createSheet("水泥");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("水泥ID");
        headerRow.createCell(1).setCellValue("型号");
        headerRow.createCell(2).setCellValue("CaO含量 (%)");
        headerRow.createCell(3).setCellValue("SiO2含量 (%)");
        headerRow.createCell(4).setCellValue("Al2O3含量 (%)");
        headerRow.createCell(5).setCellValue("地区名称");

        int rowNum = 1;
        for (SysCement cement : cementList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(cement.getCementId());
            row.createCell(1).setCellValue(cement.getModel());
//            row.createCell(2).setCellValue(cement.getCaoContent());
//            row.createCell(3).setCellValue(cement.getSio2Content());
//            row.createCell(4).setCellValue(cement.getAl2o3Content());
            row.createCell(5).setCellValue(cement.getRegionNameStr());
        }
    }

    // 工具方法：创建石子 sheet
    private void createStoneSheet(Workbook workbook, List<SysStone> stoneList) {
        Sheet sheet = workbook.createSheet("石子");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("石子ID");
        headerRow.createCell(1).setCellValue("表观密度");

        headerRow.createCell(2).setCellValue("颗粒级配");
        headerRow.createCell(3).setCellValue("颗粒尺寸");
        headerRow.createCell(4).setCellValue("地区名称");

        int rowNum = 1;
/*        for (SysStone stone : stoneList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(stone.getStoneId());
            row.createCell(1).setCellValue(stone.getBulkDensity());

            row.createCell(2).setCellValue(stone.getParticleSizeDistribution());

            row.createCell(3).setCellValue(stone.getSize());
            row.createCell(4).setCellValue(stone.getRegionNameStr());
        }
    }*/

        // 工具方法：创建砂子 sheet
/*    private void createSandSheet(Workbook workbook, List<SysSand> sandList) {
        Sheet sheet = workbook.createSheet("砂子");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("砂子ID");
        headerRow.createCell(1).setCellValue("砂细度");
        headerRow.createCell(2).setCellValue("砂类型");
        headerRow.createCell(3).setCellValue("地区名称");

        int rowNum = 1;
        for (SysSand sand : sandList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(sand.getSandId());
            row.createCell(1).setCellValue(sand.getGrainSize());
            row.createCell(2).setCellValue(sand.getType());
            row.createCell(3).setCellValue(sand.getRegionNameStr());
        }
    }*/

/*    // 工具方法：创建粉煤灰 sheet
    private void createFlyashSheet(Workbook workbook, List<SysFlyash> flyashList) {
        Sheet sheet = workbook.createSheet("粉煤灰");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("粉煤灰ID");
        headerRow.createCell(1).setCellValue("型号");
        headerRow.createCell(2).setCellValue("细度");
        headerRow.createCell(3).setCellValue("地区名称");

        int rowNum = 1;
        for (SysFlyash flyash : flyashList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(flyash.getFlyashId());
            row.createCell(1).setCellValue(flyash.getGrade());
            row.createCell(2).setCellValue(flyash.getRegionName());
            row.createCell(3).setCellValue(flyash.getRegionNameStr());
        }
    }*/
/*

    private void createFlyashSheet1(Workbook workbook, List<SysOtherAdmixtures> otherAdmixturesList) {
        Sheet sheet = workbook.createSheet("石粉");

        // 创建表头
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("石粉ID");
        headerRow.createCell(1).setCellValue("型号");
        headerRow.createCell(2).setCellValue("细度");
        headerRow.createCell(3).setCellValue("含水量");
        headerRow.createCell(4).setCellValue("28天活性指数(%)");
        headerRow.createCell(5).setCellValue("地区名称");

        // 填充数据行
        int rowNum = 1;
        for (SysOtherAdmixtures admixture : otherAdmixturesList) {
            Row row = sheet.createRow(rowNum++);

            // 石粉ID（假设为 Long/Integer）
            // 石粉ID（假设为 Long）
            Integer id1 = admixture.getAdmixturesId();
            row.createCell(0).setCellValue(id1 != null ? id1 : 0); // 直接传 Long
            // 型号（假设为 String）
            row.createCell(1).setCellValue(admixture.getModel() != null ? admixture.getModel() : "");

            // 细度（BigDecimal -> double）
            BigDecimal fineness = admixture.getFineness();
            row.createCell(2).setCellValue(fineness != null ? fineness.doubleValue() : 0.0);

            // 含水量（BigDecimal -> double）
            BigDecimal moisture = admixture.getMoistureContent();
            row.createCell(3).setCellValue(moisture != null ? moisture.doubleValue() : 0.0);

            // 28天活性指数（BigDecimal -> double）
            BigDecimal activityIndex = admixture.getActivityIndex28d();
            row.createCell(4).setCellValue(activityIndex != null ? activityIndex.doubleValue() : 0.0);

            // 地区名称（固定空值）
            row.createCell(5).setCellValue(""); // 根据需求填充实际字段
        }

        // （可选）自动调整列宽
        for (int i = 0; i < 6; i++) {
            sheet.autoSizeColumn(i);
        }
    }
*/


//    private void createFlyashSheet1(Workbook workbook, List<SysOtherAdmixtures> OtherAdmixtureslist) {
//        Sheet sheet = workbook.createSheet("石粉");
//        Row headerRow = sheet.createRow(0);
//        headerRow.createCell(0).setCellValue("石粉ID");
//        headerRow.createCell(1).setCellValue("型号");
//        headerRow.createCell(2).setCellValue("细度");
//        headerRow.createCell(3).setCellValue("含水量");
//        headerRow.createCell(4).setCellValue("28天活性指数(%)");
//        headerRow.createCell(5).setCellValue("地区名称");
//
//        int rowNum = 1;
//        for (SysOtherAdmixtures flyash : OtherAdmixtureslist) {
//            Row row = sheet.createRow(rowNum++);
//            row.createCell(0).setCellValue(flyash.getId());
//            row.createCell(1).setCellValue(flyash.getModel());
//            row.createCell(2).setCellValue(flyash.getFineness());
//            row.createCell(3).setCellValue(flyash.getMoistureContent());
//            row.createCell(4).setCellValue(flyash.getActivityIndex28d());
//            row.createCell(5).setCellValue("");
//        }
//    }
//


//    private void createFlyashSheet1(Workbook workbook,  List<SysMineralPowder> MineralPowderList) {
//        Sheet sheet = workbook.createSheet("矿粉");
//        Row headerRow = sheet.createRow(0);
//        headerRow.createCell(0).setCellValue("ID");
//        headerRow.createCell(1).setCellValue("矿粉等级");
//        headerRow.createCell(2).setCellValue("细度(%)");
//        headerRow.createCell(3).setCellValue("含水量(%)");
//        headerRow.createCell(4).setCellValue("28天活性指数(%)");
//        headerRow.createCell(5).setCellValue("来源");
//
//        int rowNum = 1;
//        for (SysMineralPowder flyash : MineralPowderList) {
//            Row row = sheet.createRow(rowNum++);
//            row.createCell(0).setCellValue(flyash.getId());
//            row.createCell(1).setCellValue(flyash.getSlagGrade());
//            row.createCell(2).setCellValue(flyash.getFineness());
//            row.createCell(3).setCellValue(flyash.getMoistureContent());
//            row.createCell(4).setCellValue(flyash.getActivityIndex28d());
//            row.createCell(5).setCellValue("");
//        }
//    }



/*
    private void createPowderSheet(Workbook workbook, List<SysMineralPowder> mineralPowderList) {
        Sheet sheet = workbook.createSheet("矿粉");

        // 创建表头
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("ID");
        headerRow.createCell(1).setCellValue("矿粉等级");
        headerRow.createCell(2).setCellValue("细度(%)");
        headerRow.createCell(3).setCellValue("含水量(%)");
        headerRow.createCell(4).setCellValue("28天活性指数(%)");
        headerRow.createCell(5).setCellValue("来源地区"); // 空列（根据需求调整）

        // 填充数据行
        int rowNum = 1;
        for (SysMineralPowder flyash : mineralPowderList) {
            Row row = sheet.createRow(rowNum++);

            // ID（假设为 Integer/Long）
            Integer id1 = flyash.getPowderId();
            row.createCell(0).setCellValue(id1 != null ? id1 : 0); // 直接传 Long

            // 矿粉等级（假设为 String）
            row.createCell(1).setCellValue(flyash.getSlagGrade() != null ? flyash.getSlagGrade() : "");

            // 细度（BigDecimal -> double）
            BigDecimal fineness = flyash.getFineness();
            row.createCell(2).setCellValue(fineness != null ? fineness.doubleValue() : 0);

            // 含水量（BigDecimal -> double）
            BigDecimal moisture = flyash.getMoistureContent();
            row.createCell(3).setCellValue(moisture != null ? moisture.doubleValue() : 0);

            // 28天活性指数（BigDecimal -> double）
            BigDecimal activityIndex = flyash.getActivityIndex28d();
            row.createCell(4).setCellValue(activityIndex != null ? activityIndex.doubleValue() : 0);

            // 空列（根据需求填充）
            row.createCell(5).setCellValue("");
        }

        // （可选）自动调整列宽
        for (int i = 0; i < 6; i++) {
            sheet.autoSizeColumn(i);
        }
    }
    // 工具方法：创建减水剂 sheet
    private void createWaterReducerSheet(Workbook workbook, List<SysWaterReducer> waterReducerList) {
        Sheet sheet = workbook.createSheet("减水剂");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("减水剂ID");
        headerRow.createCell(1).setCellValue("类型");
        headerRow.createCell(2).setCellValue("含固量");
        headerRow.createCell(3).setCellValue("减水率");
        headerRow.createCell(4).setCellValue("来源名称");

        int rowNum = 1;
        for (SysWaterReducer reducer : waterReducerList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(reducer.getReducerId());
            row.createCell(1).setCellValue(reducer.getModel());
//            row.createCell(2).setCellValue(reducer.getSolidContent());
//            row.createCell(3).setCellValue(reducer.getReducingRate());
            row.createCell(4).setCellValue(reducer.getRegionNameStr());
        }
    }
*/


        /**
         * 外加剂导出 excel
         *
         * @param
         * @return
         * @throws IOException
         * @throws UnsupportedEncodingException
         */
/*
    @PostMapping("exportAdditiveExcel")
    public ResponseEntity<byte[]> exportAdditiveExcel(@RequestBody AdditiveDTO additiveDTO) throws IOException, UnsupportedEncodingException {
        // 获取各类原材料的 ID 列表

        List<Integer> waterReducerIds = additiveDTO.getWaterReducerIds();
        List<Integer> agentIds = additiveDTO.getAgentIds();


        List<SysWaterReducer> waterReducerList = sysWaterReducerService.listWaterReduceIds(waterReducerIds);
        List<SysEfficiencyAgent> EfficiencyAgentList = sysEfficiencyAgent.listeEfficiencyAgent(agentIds);



        List<Integer> swellingagentIds=additiveDTO.getSwellingagentIds();
        LambdaQueryWrapper<SysSwellingagent> wrapper = new LambdaQueryWrapper<>();
        if (swellingagentIds != null && !swellingagentIds.isEmpty()) {
            wrapper.in(SysSwellingagent::getSwellingagentId,swellingagentIds);
        }else {
            // 如果 swellingagentIds 为空，添加一个永假条件（如 1=0）
            wrapper.apply("1 = 0");
        }

        List<SysSwellingagent> SwellingagentList = sysSwellingagentService.list(wrapper);


        // 创建一个 Excel 工作簿
        Workbook workbook = new XSSFWorkbook();
        createWaterReducerSheet(workbook, waterReducerList);
        createEfficiencyAgentSheet(workbook, EfficiencyAgentList);
        swellingagentList(workbook, SwellingagentList);

        // 将 Excel 数据写入字节数组输出流
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        workbook.write(byteArrayOutputStream);
        byteArrayOutputStream.close();

        byte[] excelData = byteArrayOutputStream.toByteArray();
        String fileName = "外加剂数据.xlsx";

        // 对文件名进行 URL 编码
        String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");

        // 设置响应头，返回 Excel 文件
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Disposition", "attachment; filename=" + encodedFileName);
        headers.add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

        return ResponseEntity.ok()
                .headers(headers)
                .body(excelData);
    }


    // 工具方法：创建增效剂 sheet
    private void createEfficiencyAgentSheet(Workbook workbook, List<SysEfficiencyAgent> waterReducerList) {
        Sheet sheet = workbook.createSheet("增效剂");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("增效剂ID");
        headerRow.createCell(1).setCellValue("类型");
        headerRow.createCell(2).setCellValue("来源名称");

        int rowNum = 1;
        for (SysEfficiencyAgent reducer : waterReducerList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(reducer.getAgentId());
            row.createCell(1).setCellValue(reducer.getModel());
            row.createCell(2).setCellValue(reducer.getRegionNameStr());
        }
    }

    // 工具方法：创建增效剂 sheet
    private void swellingagentList(Workbook workbook, List<SysSwellingagent> waterReducerList) {
        Sheet sheet = workbook.createSheet("膨胀剂");
        Row headerRow = sheet.createRow(0);
        headerRow.createCell(0).setCellValue("膨胀剂ID");
        headerRow.createCell(1).setCellValue("类型");
        headerRow.createCell(2).setCellValue("来源名称");

        int rowNum = 1;
        for (SysSwellingagent reducer : waterReducerList) {
            Row row = sheet.createRow(rowNum++);
            row.createCell(0).setCellValue(reducer.getSwellingagentId());
            row.createCell(1).setCellValue(reducer.getModel());
            row.createCell(2).setCellValue(reducer.getSourceName());
        }
    }
*/


    }
}
